小程序页面跳转传参参数值为url时参数丢失。

当参数的值为url的时候,在options中的值没有参数“?”之后字符串被截取。
例如:
let url="http://baidu.com/?a=1&b=2"
wx.navigateTo({
url: `detail?url=${url}`
})
可以使用encodeURIComponent():函数可把字符串作为 URI 组件进行编码。
let url=encodeURIComponent("http://baidu.com/?a=1&b=2")
wx.navigateTo({
url: `detail?url=${url}`
})
在获取的时候decodeURIComponent(options.url)

猜你喜欢

转载自blog.csdn.net/qq_27223987/article/details/79885514
今日推荐