vue v-for 样式赋值
v-bind:style="{'background-color': item.iconColor}">{{item.name}}v-bind:style="{'background-color': item.iconColor}">{{item.
·
<span v-for="item in data2Source">
<div class="col-md-3 col-sm-3 col-xs-3">
<span class="iconSize" v-if="item.icon === ''">
<i class="el-icon-news" v-if="item.iconColor === ''" style="background-color: #3EBAEC;"></i>
<i class="el-icon-news" v-else v-bind:style="{'background-color': item.iconColor}"></i>
<font>{{item.name}}</font>
</span>
<span class="iconSize" v-else>
<i :class="item.icon" v-if="item.iconColor === ''" style="background-color: #3EBAEC;"></i>
<i :class="item.icon" v-else v-bind:style="{'background-color': item.iconColor}"></i>
<font>{{item.name}}</font>
</span>
</div>
<div class="col-md-3 col-sm-3 col-xs-3">
<span class="iconSize" v-if="item.icon === ''">
<i class="el-icon-news" v-if="item.iconColor === ''" style="background-color: #3EBAEC;"></i>
<i class="el-icon-news" v-else v-bind:style="{'background-color': item.iconColor}"></i>
<font>{{item.name}}</font>
</span>
<span class="iconSize" v-else>
<i :class="item.icon" v-if="item.iconColor === ''" style="background-color: #3EBAEC;"></i>
<i :class="item.icon" v-else v-bind:style="{'background-color': item.iconColor}"></i>
<font>{{item.name}}</font>
</span>
</div>
</span>
直接上代码吧! v-bind:style="{'background-color': item.iconColor}" 为样式赋值,将获取的json 样式赋值给style
更多推荐
已为社区贡献4条内容
所有评论(0)