项目如图,现在的写法,针对一个订单号还好,但是如果有多个订单号,他就会点击一个,全部展开收起。想要单独控制。实在不知道改怎么写,跪求循环中的可单独展开收起的功能。谢谢大神们(本人刚毕业)
<div v-for="(item, index) in this.listOrders" class="container ">
<div id="oderDetails" ref="oderDetails" :class="showAll?'MoreDetail':'CloseDetail'">
<router-link
tag="div"
:to="/product/ + childItem.goods_pid"
v-for="(childItem, childIndex) in item.orderDetails"
:key="childIndex"
class="row goodsList">
<div class="col-xs-3 imgWrapper">
<img v-lazy="childItem.car_img"
alt="">
</div>
<div class="col-xs-9 goodInfo">
<div class="row">
<div class="col-xs-12 goodName">
{{childItem.goodsname}}
</div>
<div class="col-xs-12 goodType">
<span class="">Item ID:{{childItem.goodsid}} </span>
<span>{{childItem.car_type}}</span>
</div>
<div class="col-xs-12 goodPrice">
<span class="price">${{childItem.goodsprice}}</span>
<span class="number">/{{childItem.seilUnit}} x {{childItem.yourorder}}</span>
</div>
</div>
</div>
</router-link>
</div>
<div id="oderDetailsClick" @click="showAll = !showAll;" class="show-more text-center iconfont" >{{showAll?'':''}}</div>
</div>
你在获取数据源的时候循环插入一个bool字段,然后列表渲染只要在方法上把相应的bool改成对应的就可以了,例如@click="item.bool=!item.bool"