- 如何解决_this.setData与this.setData都无法赋值?
onLoad: function (options) { const db = wx.cloud.database({ env: 'ka-tset-pz57d' }) db.collection('readergoods').get({ success: res=> { console.log(res.data) , console.log(res.data[0].goods_name) this.setData({ goodslists: res.data, name:res.data[0].goods_name, price:res.data[0].goods_price }) } }) }, 第二种方法 onLoad: function (options) { var _this = this; const db = wx.cloud.database({ env: 'ka-tset-pz57d' }) db.collection('readergoods').get({ success: function(res) { console.log(res.data) , console.log(res.data[0].goods_name) _this.setData({ goodslists: res.data, name:res.data[0].goods_name, price:res.data[0].goods_price }) } }) }, 这两个都没有赋值成功 [图片]但是都可以console.log在控制台输出出来
2020-05-21 - 第一次使用云数据库 有点迷,这个报错该怎么解决?求助大佬
mounted(){ wx.cloud.init({ traceUser: true, env:'ka-tset-pz57d' }); const db = wx.cloud.database(); this.db.collection('readergoods').get().then(res=>{ console.log(res.data); this.goodslists=res.data; }) } 为什么我一运行就报错 Cannot read property 'collection' of undefined;at "pages/goods/main" page lifeCycleMethod onReady function TypeError: Cannot read property 'collection' of undefined
2020-05-20