无法提取二维码参数?

为何我在微信开发者工具里,用快速二维码工具编译,识别二维码。却无法提取参数?

获取代码

onLoad: function(query) {
   this.scene1 = decodeURIComponent(query.scene)
            console.log("scene1",this.scene1)


        },

提取图片代码

url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="&new_token
data="{""page"":""pages_sbjy/sbjy_3"",""scene"": ""a=99""}"

生成的二维码

img

该回答通过自己思路及引用到GPTᴼᴾᴱᴺᴬᴵ搜索,得到内容具体如下:
您的问题可能是因为您在调用 getwxacodeunlimit 接口时,没有正确设置 scene 参数。

根据您提供的代码,您设置的 scene 参数为 "a=99",但是在 onLoad 函数中,您使用了 query.scene 获取二维码中的参数。因此,您应该在 getwxacodeunlimit 接口中设置正确的 scene 参数,例如:

url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + new_token
data = '{"page": "pages_sbjy/sbjy_3", "scene": "a=99"}'

注意,这里的 scene 参数应该是一个字符串,包含了您需要传递的参数信息。在 onLoad 函数中,我们可以使用 decodeURIComponent 函数来解码这个字符串,例如:

onLoad: function(query) {
  var scene = decodeURIComponent(query.scene)
  console.log("scene", scene)
}

在上面的代码中,我们使用 decodeURIComponent 函数对 query.scene 进行解码,然后将解码后的参数输出到控制台中。这样,您就可以在小程序中正确地获取二维码中的参数了。


如果以上回答对您有所帮助,点击一下采纳该答案~谢谢