Vue引用图片(require引用和设置background)
require图片let menuPath ="assets/img/menu.png";//重新拼接 require(`@/${图片变量路径}`)<imgclass="menu":src="require(`@/${menuPath}`)"/>需要加require设置backgroundImage<img :src="require('assets/img/button.png
·
require图片
let menuPath = "assets/img/menu.png";
//重新拼接 require(`@/${图片变量路径}`)
<img
class="menu"
:src="require(`@/${menuPath}`)"
/>
需要加require
设置backgroundImage
<img :src="require('assets/img/button.png')">
<div :style="{backgroundImage:'url('+require('assets/img/book.png')+')'}">
</div>
data() {
return {
img: 'url(' + require('../../assets/img/video.png') + ')'
}
}
更多推荐
已为社区贡献20条内容
所有评论(0)