<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)
        },

 

Logo

前往低代码交流专区

更多推荐