问题:函数
当参数为url时且值含有"?",接收参数时在options中"?"以后字符串被截取编码
例子:url
let url="http://baidu.com/?a=1" wx.navigateTo({ url:'../detail?url='+url }) console.log(options.url) //获得的值http://baidu.com
缘由:spa
解析问题code
解决办法:blog
使用encodeURIComponent()
:函数可把字符串做为 URI
组件进行编码。字符串
let url=encodeURIComponent("http://baidu.com/?a=1&b=2") wx.navigateTo({ url: `detail?url=${url}` })
在获取的时候decodeURIComponent(options.url)
io