<div v-for="(item, index) in list" :class="["a", selectItem[0][index]==1?"b":"c"]" @click="changeSelectItem(0,index)"></div>
<div v-for="(item, index) in list" :class="["a", selectItem[0][index]==1?"b":"c"]" @click="changeSelectItem(1,index)"></div>
data:{
list:[]
selectItem = {
0:[0,0,0],
1:[0,0,0]
}
}
methods: {
changeSelectItem(key,index){
this.selectItem[key][index]=1
}
},
created () {
this.List = XXX//
}
vue"s foundation is weak, not very clear about its internal mechanism, when writing the code, (the whole code is about the above), found that when I call the changeSelectItem function to change the array in the selectItem object, class will not change dynamically, it is not clear whether the class binding can not be as deep as my needs in the array to bind, if not, can only manually add the class name for the dom element, looking for a big solution!