vue的style绑定background-image的方式和其他变量数据的区别

问题:使用vue加载图片变量,为了图片的自适应,需设置为背景图居中排布

<tr v-for="(item,index) in dataObj">
    <td class="video-msg" v-bind:id="item.videoid">
        <div class="videoImg fl" v-bind:style="{backgroundImage:'url(' + item.videopic + ')'}">
        </div>
    </td>
    <td v-if="item.videoisdel == 3">审核中</td>
    <td>{{item.publishdate}}</td>
    <td>sss
        <button class="delete" @click='delConfirm(item.videoid)'>删除</button>
    </td>
</tr>

行内样式的写法:

  • v-bind:style="{backgroundImage:'url(' + item.videopic + ')', backgroundRepeat:'no-repeat', backgroundPosition:'center center', backgroundSize: 'contain'}"

猜你喜欢

转载自blog.csdn.net/ddwddw4/article/details/81243366