获得URL含有中文出现乱码解决

如:

http://www.htmlx.culub/?searchWord=工商代理

当获取链接中所对应searchWord的值时,出现 '%E5%B7%A5%E5%95%86%E4%BB%A3%E7%90%86';

正确应该为:工商代理

利用函数 decodeURIComponent() 可以解决这问题,即:

decodeURIComponent(这里放传进来的值) ;

反之则用:encodeURIComponent()

原文地址:https://www.cnblogs.com/waitingbar/p/4861854.html