function urlSerilize(url) {
let result = {};
url = url.split('?')[1];
let map = url.split('&');
for (let i = 0;i < map.length;i++){
result[map[i].split('=')[0]] = map[i].split('=')[1];
}
return result;
}
let res = urlSerilize('http://www.it666.com?name=andy&age=21&sex=MALE');
console.log(res);
切割url后面的get参数,保存到对象中
最新推荐文章于 2023-10-23 09:23:20 发布