vue 实现动态绑定class属性

2017-08-26  本文已影响0人  飞鱼_JS
<span v-for="(list2,index) in lists2" :class="{'searchactive':ind2 === index}"  @click="changeBgc2(index)" >{{list2}}</span>
//----------------------------------------------------------------------------
data(){
  return {
       ind:"",
}
},
methods:{
changeBgc2:function(index){
      this.ind2=index;
    },
}
//---------------------------------------------------------------------------------------
<style>
 .searchactive {
   border-radius: 4px;
   line-height: 22px;
   padding: 1.2px 10px;
   text-align: center;
   color: rgba(16, 142, 233, 1);
   margin: 0 5px;
   cursor: pointer;
   border: 1px solid rgba(16, 142, 233, 1)!important;
 }
</style>
上一篇下一篇

猜你喜欢

热点阅读