废弃getUserInfo以后,无从下手
发布于 5 年前 作者 juanhan 18853 次浏览 来自 问答

scope.userInfo 已废弃 如何知道是否已经授权

官方 demo  有点自相矛盾,

wx.getSetting({
      success: function(res){
        if (res.authSetting['scope.userInfo']) {
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称
          wx.getUserInfo({
            success: function(res) {
              console(res.userInfo)
            }
          })
        }
      }
    })

这样写还能用吗

截图来源:https://developers.weixin.qq.com/miniprogram/dev/api/open.html#wxgetuserinfoobject

9 回复

旧的内容不能也修改下嘛?搞得一头雾水,你们的api文档真的很难看懂

马上要给客户演示了,突然出来这坑,坑惨了,紧张的弄了好久

我也刚刚碰到这样的问题。。。天了噜

我也是这个问题,怎么解决的?

var button = wx.createUserInfoButton({

type: ‘text’,

text: ‘进入游戏’,

style: {

left: window.innerWidth/2-70,

top: window.innerHeight/2+50,

width: 140,

height: 40,

lineHeight: 40,

backgroundColor: ‘#ff0000’,

color: ‘#ffffff’,

textAlign: ‘center’,

fontSize: 16,

borderRadius: 8

}

})

button.onTap((res) => {

console.log(res)

if(res.userInfo)

{

    console.log(res.userinfo)

}

tips:真机调试才显示按钮

回到顶部