When developing WeChat applet, two-dimensional arrays are needed to display information. So how to output and display the two-dimensional array? Let’s learn together.
How to output a two-dimensional array from a small program
1. First define a two-dimensional array
Page({ data:{ mapData:[ [{id:11},{id:12}], [{id:21},{id:22}], [{id:31},{id:32},{id:33}] ] } })
2. Then use two layers of wx:for loops to output.
<view class="container"> <view class="map"> <view wx:for="{{mapData}}"> <view wx:for="{{item}}"> {{item.id}} </view> </view> </view> </view>
For more WeChatmini program development tutorials, please pay attention to the PHP Chinese website.
The above is the detailed content of How to output a two-dimensional array from a small program. For more information, please follow other related articles on the PHP Chinese website!