微信扫码带参跳转小程序
在微信公众平台“开发设置”中,我们添加了一个“扫普通链接二维码打开小程序”,并且已发布,后台生成一个二维码之后,解析出来是需要带参数的,比如 https://XXX.com/pages/index/i... 等,参数大概8个左右,小程序发布以后,我们扫码后,在日志里面发现获取的参数都未undefined, 前台获取代码写在onLoad中: [代码]onLoad: [代码][代码]function[代码][代码](options) {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]let id = options.id;[代码][代码] [代码][代码]let num = options.num;[代码][代码] [代码][代码]let lang = options.lang;[代码][代码] [代码][代码]·[代码][代码] [代码][代码]·[代码][代码] [代码][代码]·[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: app.data.WebRoot + [代码][代码]"xxx"[代码][代码],[代码][代码] [代码][代码]data:{[代码][代码] [代码][代码]id:id,[代码][代码] [代码][代码]num:num,[代码][代码] [代码][代码]lang:lang[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码] [代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码] [代码]}[代码]然后怕是要转码,又改成 [代码]onLoad: [代码][代码]function[代码][代码](options) {[代码][代码] [代码][代码]let that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]let id = decodeURIComponent (options.id);[代码][代码] [代码][代码]let num = decodeURIComponent (options.num);[代码][代码] [代码][代码]let lang = decodeURIComponent (options.lang);[代码][代码] [代码][代码]·[代码][代码] [代码][代码]·[代码][代码] [代码][代码]·[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: app.data.WebRoot + [代码][代码]"xxx"[代码][代码],[代码][代码] [代码][代码]data:{[代码][代码] [代码][代码]id:id,[代码][代码] [代码][代码]num:num,[代码][代码] [代码][代码]lang:lang[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码][代码](res) {[代码][代码] [代码] [代码] [代码][代码]}[代码][代码] [代码][代码]});[代码][代码] [代码] [代码]}[代码]用decodeURIComponent转码,然而用户扫码出来所有参数还是undefined