<img src="/assets/images/a.png">
<img :src="imgPath">
const imgPath = new URL('/assets/images/a.png',import.meta.url).herf
<img :src="getImgPath(item.url)" v-for="item in imgList">
const imgList = [
{
url: 'images/a.png'
},
{
url: 'images/b.png'
},
{
url: 'images/c.png'
}
]
const getImgPath = (url)=> new URL(`/assets/${url}`, import.meta.url).href
new URL(url,import.meta.url).href
url 必须是字符串地址或者字符串拼接地址,勿使用变量