有时候我们在url中拼接中文变量,当接收时,比如前端Js接收,会显示中文乱码
http://112.234.46.42:8089/front/WisdomShop/views/login/login.shtml?userId=10005&uname=李逍遥
在js中接收query('uname') 发现是乱码,这个问题可以用如下方法解决:
在js中拼接url时,对李逍遥两次转码,encodeURI(encodeURI("李逍遥")) ,结果为%25E6%259D%258E%25E9%2580%258D%25E9%2581%25A5
在js中接收时,decodeURI(query('uname')) 值为"李逍遥"