Home  >  Article  >  WeChat Applet  >  How to output a two-dimensional array from a small program

How to output a two-dimensional array from a small program

angryTom
angryTomOriginal
2020-03-21 11:21:277220browse

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

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn