getApp()页面跳转后获取不到值,是什么问题?

小程序 文章 2022-03-18 10:20 1557 0 全屏看文

AI助手支持GPT4.0

getApp()页面跳转后获取不到值,是什么问题?getApp() can't get the value after the page jumps, what's the problem?

getApp()页面跳转后获取不到值,是什么问题?

Uni-App H5

如图:

定义一个全局变量appData 他的值为getApp(),getInfoBy()方法中通过appData获取当前登录用户的openid。

问题:页面加载完成后获取openid没问题。问题出现在调用微信支付的时侯,输入支付金额后且成功完成支付操作。完成支付操作后路由会跳转到小程序页面,这时候通过调用getInfoBy()方法,其中appData获取openid获取不到值(appData貌似被销毁了)。

测试二维码

测试步骤:微信扫码》登录》个人中心》充值金额0.01》充值

ps:小程序右下角有vConsole按钮点击后会弹出控制台,该控制台可调试查看

PS:很多办法都试了就是不行,求大佬吗解惑。

Uni app H5 is shown in the figure: define a global variable appdata, whose value is getapp(), and get the openid of the currently logged in user through appdata in getinfoby() method. Problem: there is no problem getting openid after the page is loaded. The problem occurs when calling wechat payment. After entering the payment amount, the payment operation is successfully completed. After the payment operation is completed, the route will jump to the applet page. At this time, call the getinfoby () method, where appdata gets openid and cannot get the value (appdata seems to be destroyed). Testing QR code test steps: wechat scanning code "login" personal center "recharge amount 0.01" recharge PS: there is a vconsole button in the lower right corner of the applet. After clicking, the console will pop up. The console can be debugged and checked PS: many methods have been tried, but they can't be done. Ask the boss to solve his doubts.

回答:

工号 019743:

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。


盲猜是异步的问题吧

下渝州:

uniapp移步他们社区去问咯

.:

globalData里面的openid是怎么写的?

-EOF-

AI助手支持GPT4.0