小程序 · 跳转带参数写法,兼容url的出错

3,009 阅读1分钟

跳转



let query = {url: ''}
wx.navigateTo({
  url: `/pages/detail/main?query=` + encodeURIComponent(JSON.stringify(query))
})

接收


onLoad(options) {
  console.log(JSON.parse(decodeURIComponent(options.query))) //打印时不能带提示

  let query = JSON.parse(decodeURIComponent(options.query))
  
  this.url = query.url
}