您好,欢迎来到好走旅游网。
搜索
您的当前位置:首页vue的style绑定background-image的方式和其他变量数据的区别详解

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'}"

以上这篇vue的style绑定background-image的方式和其他变量数据的区别详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

Copyright © 2019- haog.cn 版权所有 赣ICP备2024042798号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务