解码URL接收参数中的“乱码”

昨天在改一个bug,后台传过来的url中带有多个参数值,例如"%E5%BC%A0%E4%B8%89"这种需要解码获取正确的数据。
有两种解码方式。

  1. encodeURI() 函数编码过的URI 用decodeURI() 解码
  2. encodeURIComponent() 函数编码的 URI 用ecodeURIComponent() 函数解码

猜你喜欢

转载自blog.csdn.net/gua222/article/details/106397276