微信小程序遍多维数组的方法,接口返回数据如下

遍历数据如下
<block wx:for="{{storelist}}" wx:key="{{index}}">
<swiper-item style="display:flex">
<block wx:key="{{index}}" wx:for="{{item}}" wx:for-item="twodata">
<view class='xiugai {{index !== 3 ? "" : ""}}' bindtap='shoplistcli' data-sid='{{twodata.id}}' >
<image src="{{twodata.logo}}" class="slide-image"/>
</view>
</block>
</swiper-item>
</block>
1.遍历第一层数据wx:for=”{{storelist}}”
2.第二层 wx:for=”{{item}}” wx:for-item=”twodata” ,item 为遍历对象,twodata为遍历的value(这里无需加大括号)
如果为二维以上,则wx:for=”{{twodata}}” wx:for-item=”threedata”

本文介绍了如何在微信小程序中遍历多维数组。通过示例展示了一层及多层遍历的方法,包括使用`wx:for`指令配合`wx:for-item`属性进行数据迭代。
4万+





