<div :style="{backgroundImage: 'url(' + img + ')'}"></div>
或者
<div :style="{backgroundImage:`url(${img})`}"></div>
JS
data () {
return {
img: require('../../assets/img/insuranceConfirm/' + this.imgurl) // 需要拼接字符串
}
}
<div :style="{backgroundImage: 'url(' + img + ')'}"></div>
或者
<div :style="{backgroundImage:`url(${img})`}"></div>
JS
data () {
return {
img: require('../../assets/img/insuranceConfirm/' + this.imgurl) // 需要拼接字符串
}
}
本文标题:vue中background-image图片路径问题
本文链接:https://www.haomeiwen.com/subject/laajrktx.html
网友评论