因为种种原因let url = '/api/filter/getPage/90000/BILL?at=/layoutContent/03/page&title=采购申请&subTitle=采购申请一览'只把url中的汉字encodeURI转码
2 回答

哆啦的时光机
TA贡献1779条经验 获得超6个赞
let url = '/api/filter/getPage/90000/BILL?at=/layoutContent/03/page&title=采购申请&subTitle=采购申请一览'
function encodeURIForChinese(url) {
let chineseArray = url.match(/[^\x00-\xff]+/ig);
for (let i = chineseArray.length - 1; i >= 0; i--) {
url = url.replace(chineseArray[i], encodeURIComponent(chineseArray[i]));
}
return url;
}
console.log(encodeURIForChinese(url));
添加回答
举报
0/150
提交
取消