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的方式和其他变量数据的区别详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持来客网。