vue 菜单 收缩和伸展
<ul class="b1"><li v-for="(item, index) in menu" :key="index"@click="show(index)"><div>{{item.name}}</div&g
·
<ul class="b1">
<li v-for="(item, index) in menu" :key="index" @click="show(index)">
<div>{{item.name}}</div>
<ul :class ='{active:flag[index]}'>
<li v-for="(item, index) in item.children" :key="index">
{{item.name}}
</li>
</ul>
</li>
</ul>
data
flag: []
methods
show(index) {
this.flag[index] = !this.flag[index]
this.$set(this.flag,index,flag)
},
更多推荐
已为社区贡献9条内容
所有评论(0)