前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >vue style 绑定问题

vue style 绑定问题

原创
作者头像
shirishiyue
发布2019-05-28 10:32:19
1.9K0
发布2019-05-28 10:32:19
举报
文章被收录于专栏:全栈码全栈码

重构稿如下:

代码语言: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',
                }
            },
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档