小程序
小游戏
企业微信
微信支付
扫描小程序码分享
URL Link跳转的页面能获取到URL Link带的query参数吗?页面的onShow可以获取到吗
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-link.html
query获取方式:
1. onLoad 函数获取:在小程序的页面 js 文件中,可以在 onLoad 函数中通过 options 参数来获取 query 参数。例如 onLoad (options) { let linkId = options.linkId; let name = options.name; if (linkId) { this.linkId = options.linkId; } this.getDetail(); } ,其中 options 包含了通过 URL Link 传递过来的所有 query 参数.
2. getCurrentPages () 方法获取:使用 getCurrentPages() 方法获取应用页面栈,再通过 pagearr[pagearr.length - 1].options 来获取当前页面的 query 参数。如 let pagearr = getCurrentPages();let currentPage = pagearr[pagearr.length - 1];let query = currentPage.options;
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-link.html
query获取方式:
1. onLoad 函数获取:在小程序的页面 js 文件中,可以在 onLoad 函数中通过 options 参数来获取 query 参数。例如 onLoad (options) { let linkId = options.linkId; let name = options.name; if (linkId) { this.linkId = options.linkId; } this.getDetail(); } ,其中 options 包含了通过 URL Link 传递过来的所有 query 参数.
2. getCurrentPages () 方法获取:使用 getCurrentPages() 方法获取应用页面栈,再通过 pagearr[pagearr.length - 1].options 来获取当前页面的 query 参数。如 let pagearr = getCurrentPages();let currentPage = pagearr[pagearr.length - 1];let query = currentPage.options;