重构稿如下:
代码语言:javascript复制<div id="show-img" class="showUploadImg">
<li class="" style="background:url(xxx) no-repeat center center;background-size:contain;z-index:10"></li>
<i class="weui-icon-cancel" id="delImg-icon"></i>
</div>
先这样:
代码语言:javascript复制<li class="" :style="{background:'url(xxx) no-repeat center center'}" style="background-size:contain;z-index:10"></li>
这种不行。
必须把background要分离开写,如下:
代码语言:javascript复制computed: {
specialstyle(){ //样式问题
return {
'background-image' : 'url(' this.apply_info.main_pic ')',
'background-repeat': 'no-repeat',
'background-size' : 'contain',
'background-position':'center',
'z-index': 10,
//'background': 'url(' this.apply_info.main_pic ') no-repeat center center', //这两种方式不行
//'background-size': 'contain',
}
},
}