报错 ReferenceError: canIlogin is not defined?
发布于 4 年前 作者 rhou 5296 次浏览 来自 官方Issues

  是getUserProfile的回调里面不能if吗?去掉if可以正常跳转,

 data: {

    userInfo: {},
    hasUserInfofalse,
    canIloginfalse
  },
getUserProfile(){
    var that = this
   // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
    // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
    wx.getUserProfile({
      desc'用于完善会员资料'// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
      success(res) => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfotrue
        });
        if(canIlogin&&hasUserInfo)      ///////////////////////////////////////////////////////这里报错
        {
          wx.switchTab({
            url'../../pages/index/index',
            success(result)=>{
              
            },
            fail()=>{},
            complete()=>{}
          })
        }
      }
    })
  },
1 回复

canIlogin你没定义啊,你如果要用data里的canIlogin的话要写成 this.data.canIlogin

回到顶部