发送get请求时,url中解析出现乱码的解决,无法跳转,url中出现转义

使用encodeURI()和encodeURIComponent()函数将字符串转换为通用资源标识符
前提是字符串:

var uri="http://www.jxbh.cn/illegal value.htm#start";
console.log(encodeURI(uri));
// http://www.jxbh.cn/illegal%20value.htm#start
var uri="http://www.jxbh.cn/illegal value.htm#start";
console.log(encodeURIComponent(uri));
// http%3A%2F%2Fwww.jxbh.cn%2Fillegal%20value.htm%23start

猜你喜欢

转载自www.cnblogs.com/intelwisd/p/13206610.html
今日推荐