const url = "https://so.csdn.net/so/search/all?q=query&t=all&p=1&s=0&tm=0"; //测试用例
function func(url) {
let obj = {}
let i = url.indexOf("?") + 1;
let str = url.substr(i);
let arr = str.split("&")
for(let i = 0; i < arr.length;i++){
let arr1 = arr[i].split("=");
obj[arr1[0]] = arr1[1];
}
return obj
}
console.log(func(url));
07-10
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-12
3856
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-11
1208
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)