读取数据,数组下有多个数组:

wxml页面上显示:
wx:for="{{photo}}" wx:for-item="dayItem" wx:key="{{dayItem.id}}"
wx:for="{{dayItem.color}}" wx:key="{{item.colorId}}"
例子:
<view class="scroll_box" wx:for="{{photo}}" wx:for-item="dayItem" wx:key="{{dayItem.id}}">
<view class='main'>
<view class='title'>{{dayItem.chineseName}}
<text class='subTitle'>{{dayItem.englishName}}</text>
</view>
<view class='more'>查看更多
<image src="image/more.png" mode="widthFix"></image>
</view>
</view>
<view class="item_list" wx:for="{{dayItem.color}}" wx:key="{{item.colorId}}">
<image src="{{item.image}}" class="item_book_img" mode="widthFix"></image>
<view class='title'>{{item.title}}</view>
</view>
</view>
本文介绍了一个使用WXML在小程序中循环遍历复杂数据结构的例子,展示了如何通过wx:for指令和wx:key属性正确地遍历数组中的数组,并在页面上展示相应的数据。
9537

被折叠的 条评论
为什么被折叠?



