- 为什么同样是在onload函数里面,而且云函数位置在前,最后才执行云函数?
wx.cloud.callFunction({ name: 'login', date: {}, success: res => { console.log(res.result) app.globalData.openid = res.result.openid console.log(app.globalData.openid) }, }) const db = wx.cloud.database() db.collection('student').where({ _openid: app.globalData.openid }) .get({ success: function (res) { console.log(res.data.length) if (res.data.length > 0) { wx.navigateTo({ url: '../index1/index1', }) } }, }) 运行结果如下[图片]
2020-04-22 - 为什么我的这部分代码在onload里面,不会被运行,会直接被跳过?
代码像下面一样,目的是为了检测数据库有没有这个用户,如果有就跳过这个环节 const db = wx.cloud.database() db.collection('student').where({ _openid: app.globalData.openid }) .get({ success: function(res) { console.log(res.date.lenght) if (parseFloat(res.date.lenght) > 0) { wx.navigateTo({ url: '../index1/index1', }) } }, })
2020-04-21