app.js里设置全局变量index页面里获取为空?

小程序 文章 2020-08-13 10:41 707 0 全屏看文

AI助手支持GPT4.0

app.js里设置全局变量index页面里获取为空?Set global variables in app.js to get empty in index page?

app.js里设置全局变量index页面里获取为空?

这里在index里打印出来的。其它页面没问题。

操作这个userInfo为空???

This is printed out in the index. Other pages are OK. The user info operation is empty???

回答:

undefined:

你应该是userInfo还没赋值成功,你就打印userInfo了,所以是null,但之后你又赋值成功了,根据对象的引用特性,之后又会显示出来了

Zero:

新建一个小程序,demo里面就有这个问题的解决办法。官方用的是回调的方式去获取的。

stop eating:

异步问题

-EOF-

AI助手支持GPT4.0