let url = window.location.href;//http://localhost:3000/edu/edu_teacher?type=2&a=3 if(url.indexOf('?') != -1){ let obj = {}; let arr = url.slice(url.indexOf('?')+1).split('&'); arr.forEach(item => { let param = item.split('='); obj[param[0]] = param[1]; }) console.log(obj);//{type: "2", a: "3"} alert(obj.type); return obj; }else{ console.log('没有参数'); alert('没有参数'); return null; }