js
data: {
openid: null,
nickName: null,
avatarUrl: '',
list : [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
that = this;
that.setData({
openid: options.openid,
nickName: options.nickName,
avatarUrl: options.avatarUrl
})
that.information();
},
information: function (e) {
db.collection('circle').where({
_openid: that.data.openid,
})
.get({
success: function(res) {
// res.data 是包含以上定义的两条记录的数组
console.log(res.data)
console.log(res.data.length)
if (res.data.length > 0) {
console.log(res.data)
for (var p = 0; p < res.data.length; p++) {
var item = {};
item.time = res.data[p].time;
item.value = p+1;
item.content = res.data[p].content;
console.log(item.content)
list.push(item)
}
console.log(item)
}
}
})
},
wxml
<view wx:for="{{list}}" >
{{item.content}}
</view>
更新到视图的话,需要使用setData这个api
你那个list.push错了呀,应该是that.data.list.push