VM61:1 thirdScriptError app.getUserInfo is not a function ;at pages/index/index page lifeCycleMethod onShow function TypeError: 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:1 errorReport @ WAService.js:4 thirdErrorReport @ WAService.js:4 (anonymous) @ WAService.js:4 (anonymous) @ WAService.js:19 $t @ WAService.js:19 on @ WAService.js:20 sn @ WAService.js:20 (anonymous) @ WAService.js:20 (anonymous) @ WAService.js:19 L.emit @ WAService.js:8 emit @ WAService.js:6 (anonymous) @ WAService.js:9 (anonymous) @ WAService.js:6 e @ appservice?t=1556118374729:2874 n.registerCallback.t @ appservice?t=1556118374729:2874 l.forEach.t @ appservice?t=1556118374729:2874 (anonymous) @ appservice?t=1556118374729:2874 s.onmessage @ appservice?t=1556118374729:2874 app.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) {
var
that =
this
;
if
(
this
.globalData.userInfo) {
typeof
cb ==
"function"
&& cb(
this
.globalData.userInfo)
}
else
{
wx.login({
success:
function
() {
wx.getUserInfo({
success:
function
(res) {
that.globalData.userInfo = res.userInfo;
typeof
cb ==
"function"
&& cb(that.globalData.userInfo)
}
})
}
});
}
},
app.js 有这个函数,也有声明
var app = getApp()