wx.getUserInfo()获取用户头像和昵称后,打印值为空?
data: {
//用户头像
avatarUrl:"",
//用户昵称
nickName:""
},
getUserInfo(){
var that=this
wx.getUserInfo({
success:function(res){
that.setData({
avatarUrl:res.userInfo.avatarUrl,
nickName:res.userInfo.nickName
})
}
})
},
onLoad: function (options) {
this.getUserInfo()
console.log(this.data.nickName)
console.log(this.data.avatarUrl)
},