💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
> 效果如图 ![](https://box.kancloud.cn/85f5c596fa247cdcee49e67f3c1641b3_394x669.gif) > 这里实现的是三组 list 中的 点击 toggle事件 > html 代码 ``` <div id="app"> <div v-for="(item, index) in list" :key="index"> <p v-show="index === activeIndex" :key="index">{{item}}--{{index}}</p> <div style="background: cadetblue;width: 100px;height: 100px" @click="toggle(index, 1)">test</div> </div> <div v-for="(item, index) in list2" :key="index"> <p v-show="index === activeIndex2" :key="index">{{item}}--{{index}}</p> <div style="background: cadetblue;width: 100px;height: 100px" @click="toggle(index, 2)">test</div> </div> <div v-for="(item, index) in list3" :key="index"> <p v-show="index === activeIndex3" :key="index">{{item}}--{{index}}</p> <div style="background: cadetblue;width: 100px;height: 100px" @click="toggle(index, 3)">test</div> </div> </div> ``` > js 代码 ``` var vm = new Vue({ el: '#app', data() { return { list: [ '111', '222', '333', '444', '555' ], list2: [ '111', '222', '333', '444', '555' ], list3: [ '111', '222', '333', '444', '555' ], activeIndex: '', activeIndex2: '', activeIndex3: '' } }, methods: { toggle(index, num) { this.activeIndex = this.activeIndex2 = this.activeIndex3 = '' switch (num) { case 1: this.activeIndex = index; break; case 2: this.activeIndex2 = index; break; case 3: this.activeIndex3 = index break; default: } } }, }) ```