展开
<view class='investDetail' style='margin-top:30rpx;' wx:for="{{carInsurance}}" wx:key="index"> <view bindtap='clickLine' data-index="{{index}}"><view class='th1' style='font-size: 36rpx;'><text>方案{{index+1}}</text> </view> //判断展开收起 <view wx:if="{{item.show}}"></view> //展开后显示类容已省略 </view>
通过获取下标,然后判断显示
clickLine: function (e) { var that = this; var indexs = e.currentTarget.dataset.index var carInsurance = this.data.carInsurance carInsurance[indexs].show = !carInsurance[indexs].show ||false that.setData({ carInsurance: carInsurance }) },