首页 > 技术文章 > decodeURICompnent解码 对于加号(+)解码不了

handsome-jm 2019-07-08 10:36 原文

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

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

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

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

推荐阅读