咚咚咚咚队长
咚咚咚咚队长
  • 发布:2020-11-04 09:29
  • 更新:2021-10-28 10:21
  • 阅读:1233

uni.getUserInfo 回调

分类:uni-app

在微信小程序原生开发中,在相关的页面中可以使用回调来获取用户信息

// app.js  
onLunch() {  
  wx.getSetting({  
    success: res => {  
      if (res.authSetting['scope.userInfo']) {  
        wx.getUserInfo({  
          success: res => {  
              that.globalData.userInfo = res.userInfo  
              if (that.userInfoReadyCallback) {  
                that.userInfoReadyCallback(res)  
              }  
            }, 3000);  
          }  
        })  
      }  
    }  
  })  
}
// pages/index/index  
onLoad() {  
  if (!app.globalData.userInfo) {  
    app.userInfoReadyCallback = res => {  
        this.setData({  
          userInfo: res.userInfo  
        })  
      }  
  }  
}

但是在uni.app中使用上述类似写法一直没有执行回调,有没有什么办法可以在app.vue里面调请求,然后在相应页面获取数据呢,不是很想用uni.on来监听

2020-11-04 09:29 负责人:无 分享
已邀请:
j***@qq.com

j***@qq.com

请问兄弟搞定了吗?我也遇到和你一样的问题

该问题目前已经被锁定, 无法添加新回复