App()与页面的onLoad()?

微信问答 文章 2021-12-01 16:00 423 0 全屏看文

AI助手支持GPT4.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-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
如何通过按钮控制标签的显示与隐藏?经典提问,各位大佬速来讨论,为什么点击按钮后李四元素不消失呢?
uniapp没有Document.writeln()方法?
老板杀了我祭天的原因是小程序无法跳到H5的百度地图,帮帮我?
基础库2.21.1下label组件无法触发button对应的onAppShareMessage函数
从服务器获取的时间戳怎么转换为时间啊?
随便看看
微信公众号免300认证教程 5892
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 5299
小程序广告组件通过审核,但是小程序内没有显示广告? 5067
企业微信通讯录账号被管理员误/恶意删除,怎么办? 9568
问题? 9048
如何快速搭建抽奖助手小程序(无需代码知识) 6177
许涛 大哥在吗, 要解冻小程序的时候提示信息主体不一致, 能帮忙看下吗? 7472
小程序搜一搜全称搜索不显示 麻烦解决一下!谢谢 6793
我的小程序广告收款主体是个体工商户,每个月邮寄两次发票很是麻烦,我年底的时候打包邮寄一次可以么? 6128
如何解决渲染层网络错误Failed to load media? 17394