小程序体验版二维码扫描后,onLoad为啥拿不到参数?

小程序 文章 2022-01-25 15:40 811 0 全屏看文

AI助手支持GPT4.0

小程序体验版二维码扫描后,onLoad为啥拿不到参数?Why can't onLoad get the parameters after scanning the QR code of the Mini Program trial version?

小程序体验版二维码扫描后,onLoad为啥拿不到参数?

这是体验版小程序二维码解码出来后的url:https://open.weixin.qq.com/sns/getexpappinfo?appid=wx74b618259cf81f12&iswxtpa=1#wechat-redirect

我直接通过API文档中接口生成了二维码,扫描后调试模式没有显示参数,为空

但是我使用微信开发者工具的这个编译模式下,又可以获取到参数,不明白为啥。附:这个小程序是授权给第三方开发的小程序

This is the URL after decoding the QR code of the experience version applet: https://open.weixin.qq.com/sns/getexpappinfo?appid=wx74b618259cf81f12&iswxtpa=1#wechat -redirect I generated a two-dimensional code directly through the interface in the API document. After debugging, the debug mode did not show the parameters, which was empty. But when I used the compiler mode of WeChat developer tools, I could get the parameters, and I didn't understand why. Attachment: this small program is a small program authorized to be developed by a third party

回答:

刘绵绵是仙女:

解决问题了,根据文档中写的参数path去拼接自己的首页的路径+参数,然后去请求后生成。如果不传path参数,直接使用文档中的接口生成的二维码是不能读取到option参数的。https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/code/get_qrcode.html

c:

没看太懂

是体验版小程序启动页携带了参数 但是在onload里面打印不到吗

刘绵绵是仙女:是的,通过微信的接口生成的二维码
c:不是在这里设置参数就好了,干嘛还生成二维码,你接口链接让我看下
c:我懂了 你贴出生成二维码的后端代码让大家看下
刘绵绵是仙女:你这个是在小程序设置里面的,有几种方式,我想着通过后台服务去生成的方式,这样的设置比较繁琐,我们作为第三方,授权方是不喜欢我们这样去手动设置的
c:ok 解决就行
刘绵绵是仙女:这个就是我前面说的那个文档中的接口去生成的,不是我后端代码,直接用的微信的
老张:

1、把第3个console.log注释掉。

刘绵绵是仙女:我试试
刘绵绵是仙女:大佬,我注释了第255也是不行的,还是获取不到url
苒苒:

options

刘绵绵是仙女:我试试
刘绵绵是仙女:这个是没用的,只是参数的命名问题

-EOF-

AI助手支持GPT4.0