程序 页面 数据 丢失 繁體版
原文   原文链接

问题:函数

    当参数为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

相关文章
相关标签/搜索
每日一句
    每一个你不满意的现在,都有一个你没有努力的曾经。
本站公众号
   欢迎关注本站公众号,获取更多信息