javascript - 为什么一个类没有定义login方法和getUserInfo方法却还能调用?
问题描述
在WxService中有如下语句:
class Service { ....没有找到login和getUserInfo的定义 }export default Service
在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}) },})
为什么可以执行this.WxService.login()和this.WxService.getUserInfo()?
问题解答
回答1:谢邀。
this.WxService是微信封装的对象,对外是隐藏的。
ps:另外微信还有自己的协议weixin://类似http://
回答2:this.WxService是微信封装的对象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 }})
相关文章:
1. angular.js - 用angular2-cli打包项目之后,跳转路由刷新会报404的错误2. angular.js - angular2动态显示隐藏组件问题3. angular.js - 在用会话存储传递参数时,使用angularjs冲突4. angular.js - 请教angularjs里html和js通信的问题5. jquery - angularjs的数据为什么渲染不到页面上?数据获取到了,我的代码哪里出了错了?6. angular.js - 我想实现打印angular $scope数据,代码如何实现呢?求教(如下图)7. node.js - 怎么在初始化的时候使得一个子组件不加载?8. python - 如何在docker上部署pyspider9. python - Ubuntu16.04LTS登录后只显示屏保10. Python中的内列表问题,真的很困惑