vue 循环多个标签,点击标签变色,再点击取消,可以同时点击多个


效果:

 

 

<div class="relFacilityTitcon">
          <i v-for="(item,index) in facilityList" :key="index" @click="changeSpan(index);" :class="{'bgcolor':spanIndex.indexOf(index)>-1}" >{{item}}</i>
</div>

 

 data:{

spanIndex:[],

}

methods: {
           
            changeSpan(index){
                let arrIndex = this.spanIndex.indexOf(index);
                // console.log(arrIndex);
                
                if(arrIndex>-1){
                    this.spanIndex.splice(arrIndex,1);
                }else{
                    this.spanIndex.push(index);
                }
            },

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM