VM61:1 thirdScriptErrorapp.getUserInfo is not a function;at pages/index/index page lifeCycleMethod onShow functionTypeError: app.getUserInfo is not a function at t.onShow (http://127.0.0.1:15828/appservice/pages/index/index.js:104:9) at t.<anonymous> (http://127.0.0.1:15828/appservice/__dev__/WAService.js:19:13907) at $t (http://127.0.0.1:15828/appservice/__dev__/WAService.js:19:30381) at on (http://127.0.0.1:15828/appservice/__dev__/WAService.js:20:235) at sn (http://127.0.0.1:15828/appservice/__dev__/WAService.js:20:573) at Function.<anonymous> (http://127.0.0.1:15828/appservice/__dev__/WAService.js:20:3006) at L.<anonymous> (http://127.0.0.1:15828/appservice/__dev__/WAService.js:19:1500) at L.emit (http://127.0.0.1:15828/appservice/__dev__/WAService.js:8:15814) at Object.emit (http://127.0.0.1:15828/appservice/__dev__/WAService.js:6:14059) at Function.<anonymous> (http://127.0.0.1:15828/appservice/__dev__/WAService.js:9:16174)console.error @ VM61:1errorReport @ WAService.js:4thirdErrorReport @ WAService.js:4(anonymous) @ WAService.js:4(anonymous) @ WAService.js:19$t @ WAService.js:19on @ WAService.js:20sn @ WAService.js:20(anonymous) @ WAService.js:20(anonymous) @ WAService.js:19L.emit @ WAService.js:8emit @ WAService.js:6(anonymous) @ WAService.js:9(anonymous) @ WAService.js:6e @ appservice?t=1556118374729:2874n.registerCallback.t @ appservice?t=1556118374729:2874l.forEach.t @ appservice?t=1556118374729:2874(anonymous) @ appservice?t=1556118374729:2874s.onmessage @ appservice?t=1556118374729:2874app.js? [sm]:39 |
为什么加载userinfo会报错,之前一直都可以的!难道跟云函数有关?
var that = this app.getUserInfo(function (userInfo) { that.setData({ userInfo: userInfo }) console.log("user的值:", userInfo) }) wx.getSystemInfo({ success: (res) => { this.setData({ windowHeight1: res.windowHeight, windowWidth1: res.windowWidth, autoplay: true }) }, |
为什么加载userinfo会报错,之前一直都可以的!难道跟云函数有关?

看看 app.js里的getUserInfo函数。
另外,当前页里,有没有const app = getApp()
getUserInfo:function(cb) {varthat =this;if(this.globalData.userInfo) {typeofcb =="function"&& cb(this.globalData.userInfo)}else{wx.login({success:function() {wx.getUserInfo({success:function(res) {that.globalData.userInfo = res.userInfo;typeofcb =="function"&& cb(that.globalData.userInfo)}})}});}},app.js 有这个函数,也有声明
var app = getApp()