//html
<div v-for="(item, index) in data" :class="["container", {"show": firstSwitchArr[index]}]">
//js
data: {
firstSwitchArr: [true, false, false, false, false],
data: data
},
methods:{
switchShow(index) {
this.$set(this.firstSwitchArr, index, !this.firstSwitchArr[index])
}
}
//csss
.container{display:none}
.container.show{display:block}
vue project has a page, there are many containers for displaying data, which can be shown and hidden and divided into primary list and secondary list. The containers for displaying data are traversed through data, and there can be as many as you want. The method I implemented above does not quite meet the requirements. Is there a better way to implement it?