linjiu0505
wx.getLaunchOptionsSync()获取小程序启动时的参数:

path 启动小程序的路径

scene   启动小程序的场景值

query   启动小程序的 query 参数

shareTicket   shareTicket,详见获取更多转发信息

referrerInfo  来源信息。从另一个小程序、公众号或 App 进入小程序时返回。否则返回 {}。
// 启动参数为1个的时候,案例如下,仅供自己后续复习:
let launchRes = wx.getLaunchOptionsSync() // 以下是业务逻辑,不同情况业务逻辑不同 if (launchRes.path === \'pages/house/house\' && \'Id\' in launchRes.query && launchRes.query.Id) { const Id = launchRes.query.Id wx.setStorageSync(\'Id\', Id) }

 // 启动参数多个时,案例如下,仅供自己后续复习:
let launchRes = wx.getLaunchOptionsSync()
console.log(\'小程序启动参数---\', launchRes)
if (launchRes.path === \'moduleRole/pages/moreDetail/moreDetail\' && \'scene\' in launchRes.query && launchRes.query.scene) {
const scene = decodeURIComponent(launchRes.query.scene)
let reportId = \'\'
if (scene.indexOf(\'&\') !== -1) {
const sceneArr = scene.split(\'&\')
this.setState({
reportId: sceneArr[0]
})
reportId = sceneArr[0]
} else {
this.setState({
reportId: scene
})
reportId = scene
}
}
 

 

分类:

技术点:

相关文章:

  • 2021-12-05
  • 2021-11-29
  • 2021-05-26
  • 2022-12-23
  • 2021-04-09
  • 2022-01-18
  • 2022-01-26
  • 2021-07-20
猜你喜欢
  • 2021-04-22
  • 2021-09-29
  • 2021-10-09
  • 2021-07-30
  • 2021-04-22
相关资源
相似解决方案