微信小程序----多次扫描不同二维码的携带参数问题

// app.js处理。
onLaunch(options) {
  // 冷启动时在该处获取参数,将参数传递到globalData全局对象下。
  this.globalData.query = options.query || {}
  if (options.referrerInfo) { // 小程序跳小程序有的同学会使用extraData,有的同学会直接拼接在path上
    this.globalData.query = Object.assign(this.globalData.query, options.referrerInfo.extraData)
  }
},
onShow(options) { 
  // 热启动时在该处获取参数,将参数传递到globalData全局对象下。
  this.globalData.query = options.query || {}
  if (options.referrerInfo) { // 小程序跳小程序有的同学会使用extraData,有的同学会直接拼接在path上
    this.globalData.query = Object.assign(this.globalData.query, options.referrerInfo.extraData)
  }
},
globalData: {
  query: {}
}
// 落地页js
const app = getApp()
onLoad(options) {
  this.setData({
    partJobId: options.xxx || app.globalData.query.xxx || ''
  })
}
posted @ 2022-01-15 14:31  YoYo/切克闹  阅读(335)  评论(0编辑  收藏  举报