<div class="newsImg" :style="' background-image:  url('+newsImg+')'"></div>

//css:
 #news_model .newsImg{
    width: 320px; height: 180px; background-size: contain; background-repeat: no-repeat;  text-align: center;background-color:#fff;background-position:center center;
  }

这里需要注意:
1.动态渲染数据必须是:style=”“才能加入新数据
2.白色背景图background最好使用background-image等的分写,因为这里如果直接background设置图片的话,css先加载,然后到:style的部分,background直接把image,color,position给吃掉,所以,写在.newsImg的属性都会被清理掉,从而样式无法生效。

Logo

前往低代码交流专区

更多推荐