如下图所示,在onload里写的查数据库的方法,却在onready之后打印出结果
具体方法如下:
onLoad:function(options){
this.searchInfo()
},
searchInfo:function(){
console.log(“onshow…”)
const db = wx.cloud.database()
console.log(“onshow111”)
db.collection(‘problem’).where({
_openid: this.data.openid,
}).get({
success: res => {
this.setData({
items: JSON.stringify(res.data, null, 2)
})
console.log(“123:”, this.data.items)
},
fail: err => {
wx.showToast({
icon: ‘none’,
title: ‘查询记录失败’
})
}
})
}