遍历Array确实很好用,但遍历Map似乎不可行,是我用错了吗?
js代码如下:
Page({
data: {
array: [],
map_month_to_gifts: {},
array_month_to_gifts:[]
}
}
wxss代码如下:
<!--遍历数据-->
<view class="grid">
<view class="card short-card" wx:for="{{array_month_to_gifts}}" wx:for-item="giftItem">
<view> <text class="title">{{giftItem.month}}</text> </view>
<view> <text class="title">{{giftItem.gifts}}</text> </view>
</view>
</view>
<!--遍历Map,该Map是month到gift array的映射表-->
<view class="grid">
<view class='map_month_to_gifts' wx:for='{{map_month_to_gifts}}' wx:for-index="key">
<text>{{key}}:{{item}}</text>
</view>
</view>