vue v-for循环多个标签,点击标签变色,再点击取消,可以同时多选点击多个
vue v-for循环多个标签,点击标签变色,再点击取消,可以同时多选点击多个效果:html:<div class="relFacilityTitcon"><i v-for="(item,index) in facilityList" :key="index" @click="changeSpan(index);" :class="{'bgcolor':spanIndex.ind
·
vue v-for循环多个标签,点击标签变色,再点击取消,可以同时多选点击多个
效果:
html:
<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:
data:{
spanIndex:[],
}
vue:
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);
}
},
更多推荐
已为社区贡献6条内容
所有评论(0)