100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 微信小程序分享二维码扫码进入如何获取参数 小程序码进入参数为啥拿不到;

微信小程序分享二维码扫码进入如何获取参数 小程序码进入参数为啥拿不到;

时间:2018-09-16 22:24:43

相关推荐

微信小程序分享二维码扫码进入如何获取参数 小程序码进入参数为啥拿不到;

// 在 (指定分享页面)如 index/index.js 页面里拿data: {targetPath: '', // 要去的页面路径targetArguments: '' // 路径后面拼接的参数},onLoad (options) {// 我需要拿到path知道去哪个路径// 剩下的全部拼接过去// url='/pages/pageA/wherePath?argument1=a1&argument2=a2'console.log(options, 'options')// 这里约定如果是普通按钮分析传一个path(是通过分享进来之后去哪个页面得路径)const {scene, path } = options// 二维码编译if (scene) {// id=1266215038515748866&pa=1=> ["id=1266215038515748866", "pa=1"]const path = decodeURIComponent(scene).split('&')let obj = {}path.map((item, index) => {let newArr = item.split('=')obj[newArr[0]] = newArr[1]})// scene传过来的值全部丢到obj对象里// obj={id: "1266215038515748866", pa: "1"}console.log(obj, 'opObj')}// 普通分享进来的if (path) {// 边成 'ar1=1&ar2=2&ar3=3'let arr = Object.keys(options)let newArr = []for (let item of arr) {newArr.push(`${item}=${options[item]}`)}this.targetPath = paththis.targetArguments = newArr.join('&')this.toPath()}},// wapy项目,原生可以忽略methodsmethods: {toPath () {wx.reLaunch({// 跳转得路径url: `/pages/pageA/${this.targetPath}?${this.targetArguments}`})}}```

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。