获取地址后将数据转换为对象
let obj=turnUrl(url); console.log(obj); function turnUrl(url){ let num = url.indexOf("?"); url = url.substring(num+1); let arr = url.split("&"); let obj={}; for(let i=0;i<arr.length;i++){ let newArr=arr[i].split("="); obj[newArr[0]]=newArr[1]; } return obj; }