小程序
小游戏
企业微信
微信支付
扫描小程序码分享
res.data是找得到的,然后我想判断数据库里有这条记录就可以继续,没有就跳转到首页去。用if判断的,为什么直接跳过if步骤没有执行呢?求大佬解释。
3 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
author不是有数据?你if判断条件不成立当然不会执行里面的代码了。
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
有信息所以不进if
onLoad: function (options) {
that = this
wx.cloud.callFunction({
name: 'login'
}).then(res => {
var openid=res.result.openid
db.collection('user').doc(openid).get({
success: function(res) {
console.log(res.data[0].author)
if(res.data[0].author==''){
wx.showToast({
title: '请先获取信息',
icon: 'success',
duration: 2000,
})
wx.switchTab({
url: '/pages/list/list'
});}else{console.log('信息存在');}
}
that.setData({
openid: openid})
console.log(openid)
}),
that.jugdeUserLogin()
},
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
author不是有数据?你if判断条件不成立当然不会执行里面的代码了。
有信息所以不进if
onLoad: function (options) {
that = this
wx.cloud.callFunction({
name: 'login'
}).then(res => {
var openid=res.result.openid
db.collection('user').doc(openid).get({
success: function(res) {
console.log(res.data[0].author)
if(res.data[0].author==''){
wx.showToast({
title: '请先获取信息',
icon: 'success',
duration: 2000,
})
wx.switchTab({
url: '/pages/list/list'
});}else{console.log('信息存在');}
}
})
that.setData({
openid: openid})
console.log(openid)
}),
that.jugdeUserLogin()
},