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

跳转

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
}

复制代码
相关文章
相关标签/搜索