:srcๅŠจๆ€ๅฏผๅ…ฅๅ›พ็‰‡่ทฏๅพ„

ๅฏนไบŽwebpack

1
const img = require(`./img/${name}.png`)
1
<img :src="img" />

ๆˆ–่€…็›ดๆŽฅๅœจhtmlไธญไฝฟ็”จ

1
2
<img :src="require(`./img/${name}.png`)" />
<img :src="require(`@/img/${name}.png`)" />

ๅฏนไบŽvite

1
2
// ..
activeIcon: new URL('@/assets/icon/intelligent-contro.png', import.meta.url).href,
1
2
3
4
5
<img
:src="item.activeIcon"
height="40"
alt=""
>