set it to responsive data first
for (let i = 0; i < _this.myCollectList.length; iPP) {
_this.$set(_this.myCollectList[i], 'selected', false)
}
the data can be changed at this time, and the view will change
selectMyCollectList(item,index) {
item.selected = !item.selected;
}
this.$set
this.$set(item, 'selected', !item.selected)
:key="index"
key is the
of the index in the array bound to your loop.
selectMyCollectList(item,index) {
item.selected = !item.selected;
}
there is no problem with this method, you can try to print to the page to see the data changes, there should be a problem elsewhere.
<span>{{item.selected}}</span><i class="el-icon-check" v-show="item.selected"></i>
Click to change the data, and you have to change the data in data. This method is changed as follows:
selectMyCollectList(item,index) {
this.myCollectList[index]['selected']=!this.myCollectList[index]['selected'];
}
is the subject of the old version of vue? I also encountered this problem in my recent interview, but my page data is updated in real time, and I don't know why I ran through my project with the subject's code.