收藏
回答

在微信开发者工具上能获取到头像的url,但是在手机上测试(已授权),头像的url为空?

wx.getUserInfo({

            success: res => {

              this.globalData.userInfo = res.userInfo

              this.globalData.nickname = res.userInfo.nickName

              //获取用户头像

              var userInfo = res.userInfo

              var avatarUrl = userInfo.avatarUrl; //获取微信用户头像存放的Url 

              wx.getImageInfo({

                src: avatarUrl,

                success: function (res) {       //访问存放微信用户头像的Url 

                  that.globalData.userimg = res.path

                }

              })

              console.log(that.globalData.userimg)

              if (this.userInfoReadyCallback{

                this.userInfoReadyCallback(res)

              }


回答关注问题邀请回答
收藏

2 个回答

登录 后发表内容
问题标签