<script>
let url = "http://witmax.cn/index.php?key0=0&key1=1&key2=2";
let hongdou = url.indexOf("?"); //检索
let str = url.slice(hongdou+1); //选取
let arr = str.split("&"); //分割
let result =[];
let obj = {};
for(let i=0;i<arr.length;i++){
result = arr[i].split("="); //分割
obj[result[0]] = result[1];
}
console.log(obj);
</script>