decodeURIComponent 与特殊符号
问题地方
获客网页、获客文件的参数是从链接带过来的,里面解析的时候用到了 decodeURIComponent 方法,报错白屏。
原因
由于 decodeURI 转码时,通过%进行解析,如果字符串中存在%,则会出现 URI malformed


解决办法
const data =
location.query.data && JSON.parse(decodeURIComponent(location.query.data.replace(/%/g, '%25')))
总结
慎用路由传参的形式,这个参数非常长,长度 4140 个字节,把 base64 图片也传进来了,建议换一种方式。
最后更新于
这有帮助吗?