如题,官方文档是这样写的:
在小程序获取 scene 值
scene 字段的值会作为查询参数传递给小程序。用户扫描该码进入小程序后,开发者需在对应页面获取的码中 scene 字段的值,再做处理逻辑。使用如下代码可以获取到二维码中的 scene 字段的值。调试阶段可以使用开发工具的条件编译自定义参数 scene=xxxx 进行模拟,开发工具模拟时的 scene 的参数值需要进行 urlencode
Page({
onLoad (options) { // options 中的 scene 需要使用 decodeURIComponent 才能获取到生成二维码时传入的 scene
const scene = decodeURIComponent(options.scene)
}
})
但是小游戏中不知道这个Page是在哪里,是否可通过wx.getLaunchOptionsSync获取到二维码附带的参数?烦请官方解答一下。
https://developers.weixin.qq.com/minigame/dev/api/system/life-cycle/wx.onShow.htmlwx.onShow 中获取。
onShow里面需要通过decodeURIComponent方法来获取吗?二维码生成那里的scene又应该怎么填值?开发者工具不能通过扫码来调试具体的参数结构吗?能否给个示例啥的参考一下