查看运维中心的错误列表, 发现这个错误,

看起来应该是 调用wx.createUserInfoButton接口之后的onTap回调中 res.userInfo中的nickName是undefined,

请问一下 什么情况下会导致nickName为空呢?  我这里已经先先判断了userInfo为空的情况的.

Cannot read property 'nickName' of undefined;at tap callback function


贴代码  


var button = wx.createUserInfoButton({
type: "text",
   text: "微信登陆",
   image: "",
   style: {
left: x,
       top: y,
       width: 150,
       height: 48,
       lineHeight: 48,
       backgroundColor: "#09bb07",
       color: "#ffffff",
       textAlign: "center",
       fontSize: 22,
       borderRadius: 24
   }
});
button.onTap((res) => {
console.log("用户授权:", res);
   if(res.userInfo) {
WindowManage.showMiniLoding();
       UserInfo.GetInstance().init(res.userInfo);
       button.destroy();
       callBack()
}
});



init (userInfo) {
this.nickName = userInfo.nickName
   this.avatarUrl = userInfo.avatarUrl
   this.gender = userInfo.gender //性别 0:未知、1:男、2:女
    // .......
}



展开全部
收起
0回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部