话不多说,上代码
.vue文件
<div v-for="(i, index) in List" :key="index">
<span @click="handle(i, index)"
></span>
<span v-show="activeIndex === modelIndex" >-</span>
js文件
data(){returnactiveIndex: -1, // 初始化点击的索引值}
methods: {
handle=(i, index) {
//实现显示隐藏切换
if (this.activeIndex == -1) {
this.activeIndex = index;
} else {
this.activeIndex = -1;
}
},
做完记录