vue class style的几种用法

这几种是我平常经常用的常规用法,并不是全部用法

class第一种用法:对象,true,false控制

this.$store.state.threeD.isactive:布尔,用来控制activeclass这个类是否显示

<span :class="{'bodstyle':true, 'activeclass':this.$store.state.threeD.isactive}">报表</span>

class第二种用法:三目运算

<span class="iconfont" :class="index === 0? 'icon-shiliangzhinengduixiang' : 'icon-shiliangzhinengduixiang'"></span>

style的第一种用法:数据的动态变化

<span class="one" v-for="(item, index) in datastye" :key="index">
    <span class="one-two" :style="{color: item.color}">
       {{item.num}}
    </span><br>{{item.type}}
</span>

style的第二种用法:三目运算

<span :style="{color:(index==0?arr.conFontColor:'#000')}">跳转</span>

猜你喜欢

转载自blog.csdn.net/zhumizhumi/article/details/83548408
今日推荐