三十七、小程序页面跳转传参参数值为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)
---------------------
作者:beanLau
来源:CSDN
原文:https://blog.csdn.net/qq_27223987/article/details/79885514
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自www.cnblogs.com/deng-jie/p/10032281.html
今日推荐