后台获取多维数组,小程序动态循环实现选项卡
数据格式如下:
实现效果:
废话不多说,直接上代码:
//这里是循环选项卡
<view class="navbar">
<view wx:for="{{allarrm}}" wx:key='{{index}}' data-idx="{{index}}" class="item {{currentTab==index ? 'active' : ''}}"
wx:for-item='itemaa' bindtap="navbarTap">
<text>{{itemaa.fName}}</text>
</view>
</view>
<view>
//这里是循环原数组,但是取值为原数组中的det
<view wx:for-items="{{allarrm}}" wx:for-item='itemaa' wx:key='{{index}}' data-idx="{{index}}">
<!-- <view wx:for="{{navbar}}" data-idx="{{index}}"class="item {{currentTab==indexs ? 'show': 'hide'}}">
<view hidden="{{currentTab!==index}}"></view> -->
<view hidden="{{currentTab!==index}}" data-id="{{index}}" class="scanning" bindtap="scanCode">
<image src="../../../imgs/scan.png"></image>
<text>扫一扫</text>
</view>
<scroll-view hidden="{{currentTab!==index}}" scroll-y="true" style="height: 500rpx;">
<view wx:for-items="{{allarrm[index].detmain}}" wx:key="{{wxId}}" data-ddid="{{index}}">
<view class="detaillist">
<view class="table">
<!-- <view class="tr" wx:for="{{parmsupCont}}"> -->
<view class="td" class="ordername">{{item.valueName}}</view>
<!-- <view class="td" class="ordernum">{{arrRelNum[currentTab][index]}}</view> -->
<view class="td" class="ordernum">{{item.RekNum}}</view>
<view class="num-subtraction" catchtap="neckSubm" data-index='{{index}}'>-</view>
<!-- <view class="td" class="orderprice">{{item.RelNum}}</view> -->
<view class="td"
class="{{item.RelNum == parmsCont[currentTab][index].RelNum ? 'orderprice' : 'orderprice-two'}}">
{{item.RelNum}}</view>
<view class="num-add" catchtap="neckAddm" data-index='{{index}}'>+</view>
<!-- </view> -->
</view>
</view>
</view>
</scroll-view>
</view>
<view hidden="{{currentTab!==index}}" wx:for="{{allarrm}}" wx:key='{{index}}' data-id="{{index}}">
<view class="allbut1" id="{{index}}" wx:if="{{allarrm[index].upor==false}}">
<view bindtap="up" class='but1'>上传数据</view>
</view>
<view class="allbut1" id="{{index}}" wx:if="{{allarrm[index].upor==true}}">
<view class='but1'>数据已上传</view>
</view>
<view class="allbut1" id="{{index}}" wx:if="{{upName==true}}">
<view bindtap="goName" class='but1'>填写姓名</view>
</view>
</view>
取值的问题 that.data.currentTab区分选项卡,e.target.dataset.index区分循环的数组中的哪个值。