There are the following statements in WxService:
class Service {
....没有找到login和getUserInfo的定义
}
export default Service
There are the following statements in app.js:
import WxService from 'helpers/WxService'
APP({
WxService: new WxService,
getUserInfo() {
return this.WxService.login()
.then(data => {
console.log(data)
return this.WxService.getUserInfo()
})
.then(data => {
console.log(data)
this.globalData.userInfo = data.userInfo
return this.globalData.userInfo
})
},
})
Why can this.WxService.login() and this.WxService.getUserInfo() be executed?
phpcn_u15822017-06-26 10:59:41
Thanks for the invitation.
This.WxService is the object packaged by WeChat and is hidden from the outside world.
ps: In addition, WeChat has its own protocol weixin:// similar to http://
扔个三星炸死你2017-06-26 10:59:41
this.WxService is the object packaged by Weixin
https://mp.weixin.qq.com/debu...
wx.getUserInfo({
success: function(res) {
var userInfo = res.userInfo
var nickName = userInfo.nickName
var avatarUrl = userInfo.avatarUrl
var gender = userInfo.gender //性别 0:未知、1:男、2:女
var province = userInfo.province
var city = userInfo.city
var country = userInfo.country
}
})