App()与页面的onLoad()?

灏忕▼搴� 文章 2021-12-01 16:00 26 0 全屏看文

App()与页面的onLoad()?App() and onLoad() of the page?

App()与页面的onLoad()?

在小程序的app.js中的onLaunch向服务器请求数据后,把数据用wx.setStorageSync保存起来

然后到页面中去使用wx.getStorageSync去获取,清缓存后编译就拿不到wx.setStorageSync保存起来的数据,(不清缓存)再编译一次才可以拿到。

个人觉得是同步异步的问题:网页中的onLoad与执行完了wx.getStorageSync,但wx.setStorageSync还未执行。

怎么解决?

After onlaunch in app.js of the applet requests data from the server, save the data with wx.setstoragesync, and then go to the page to use wx.getstoragesync to obtain it. After clearing the cache, the data saved by wx.setstoragesync will not be available after compiling (unclear cache) and compiling again. Personally, I think it's a problem of synchronization and asynchrony: onload in the web page and wx.getstoragesync have been executed, but wx.setstoragesync has not been executed yet. How?

鍥炵瓟锛�

老张:

写一个大家都调用的app.funcC,里面的逻辑是先func A再fucnB

在所有page的onLoad里,app.funcC,完事。

米修:

123

-EOF-