<view wx:for="{{matchinglove}}" wx:for-item="item" wx:key="key">
<view class="myMenuItem" wx:for="{{item.matchinglove1}}" wx:for-item="item2" wx:key="key">
<image class="myMenuItemIcon" src="{{item2.avatar}}"></image>
<view class="myMenuName">{{item2.nickName}}</view>
</view>
</view>
页面展示没东西,此时对象数组里面有数据
下面为js逻辑
var matchinglove = [];
var matchinglove1 = [];
obj = {};
matchinglove1 = []; //得清空,要不前面的值还存在
obj.openId = openId;
obj.avatar = app.globalData.avatar;
obj.nickName = app.globalData.nickName;
obj.sex = app.globalData.sex;
matchinglove1.push(obj);//将对象添加到数组对象
obj = {};
obj.openId = matchinguser[j].openId;
obj.avatar = lovepic;
obj.nickName = "匹配成功";
obj.sex = "";
matchinglove1.push(obj);//将对象添加到数组对象
obj = {};
obj.openId = matchinguser[j].openId;
obj.avatar = matchinguser[j].avatar;
obj.nickName = matchinguser[j].nickName;
obj.sex = matchinguser[j].sex;
matchinglove1.push(obj);//将对象添加到数组对象
matchinglove.push(matchinglove1);//将对象数组添加到数组对象
数据同步到视图,需要使用setData哈
<view wx:for="{{matchinglove}}" wx:for-item="item" wx:key="key">
<view class="myMenuItem" wx:for="{{item}}" wx:for-item="item2" wx:key="key">
<image class="myMenuItemIcon" src="{{item2.avatar}}"></image>
<view class="myMenuName">{{item2.nickName}}</view>
</view>
</view>
wx:for="{{item}}" 这样写就行。