decodeURICompnent解码 对于加号(+)解码不了

Posted handsome-jm

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了decodeURICompnent解码 对于加号(+)解码不了相关的知识,希望对你有一定的参考价值。

使用javascript的decodeURIComponent函数解码查询字符串时,处理不了"+"

var q = ‘‘
decodeURIComponent(q.replace(/\+/g, ‘%20‘))

即在调用decodeURIComponent函数之前要先把+替换为%20,这样就没有问题了

摘自:http://outofmemory.cn/code-snippet/3585/fix-js-decodeURIComponent-plus-issue

以上是关于decodeURICompnent解码 对于加号(+)解码不了的主要内容,如果未能解决你的问题,请参考以下文章