微信小程式的巢狀迴圈
阿新 • • 發佈:2018-11-15
微信小程式的巢狀迴圈
聽說最近微信小程式開發火熱,不久前做了一個小程式測試,由於要取日期及下面資料。迴圈巢狀還是搞了又好一會兒。
下面是程式碼:
資料:
var DateShow=[
[{name:111},{name:666},{name:555},{name:333}],
[{name:”fff”},{name:”bjb”},{name:”jknvjdnf”},{name:”hnn”}],
[{name:”jjj},{name:”hhh”},{name:”hhh”},{name:”gggg”}]
]
方法1:
<view class="todaySession" wx:for="{{DateShow}}" wx:key="item" > <view class="Sessions" wx:for="{{item}}" wx:for-item="items" wx:key="items"> <view class="Sessionstime1">{{items.name}}</view> </view> </view>
方法2:
<view class="todaySession" wx:for="{{DateShow}}" wx:key="item" wx:if="{{reshow[index]}}"> <view class="Sessions" wx:for="{{DateShow[index]}}" wx:for-item="items" wx:key="items"> <view class="Sessionstime1">{{items.name}}</view> </view> </view>