如何在vue中定位特定的ul?

时间:2018-06-05 05:57:08

标签: javascript css vue.js

点击我想扩展特定的ul,但它正在扩展每个ul.i'm无法定位单个ul。

.ul {
  list-style: none;
  right: 25px;
  bottom: 10px;
  height: 60px;
  overflow: hidden;
  width: 200px;
  border-bottom: 1px solid #cfdada;
}

.landingPage ul.activeClass {
  overflow: auto;
}
<div class="pageContent" v-for="(item,index) in dataBox[selectedTab]">
                    <span v-for="(e,i) in dataBox[selectedTab][index]">
                        <h4>{{i}}</h4>
                        <ul v-bind:class="{activeClass:isActive}">
                            <li v-for="m in e">{{m.name}}</li>
                        </ul>
                        <span v-if="!isActive" v-on:click="{isActive=!isActive}" class="moreIcon">More..</span>
                    </span>
                </div>

1 个答案:

答案 0 :(得分:0)

isActive应设置为每个对象e,您应该像这样更改代码:

&#13;
&#13;
computed: {
  activeDataBox () {
    return this.dataBox.map(e => {
      e.isActive = false
      return e
    })
  }
}
&#13;
<div class="pageContent" v-for="(item,index) in activeDataBox[selectedTab]">
  <span v-for="(e,i) in activeDataBox[selectedTab][index]">
    <h4>{{i}}</h4>
    <ul v-bind:class="{activeClass:e.isActive}">
      <li v-for="m in e">{{m.name}}</li>
    </ul>
    <span v-if="!e.isActive" v-on:click="{e.isActive=!e.isActive}" class="moreIcon">More..</span>
  </span>
</div>
&#13;
&#13;
&#13;