话不多说直接上代码
data() {
return {
hotbg:`url(${this.$imgUrl}index/top.png)no-repeat`
}
},
<view :style="{'--hotbg':hotbg}">
</view>
.top{
&::before{
content: "";
display: inline-block;
width: 50rpx;
height: 30rpx;
margin-right: 4rpx;
background: var(--hotbg);
background-size: 100% 100%;
}
}