Appearance
如何获取url参数?
javascript
//封装函数getUrlParams, 将URL地址的参数解析为对象
function getUrlParams(url){
let obj = {};
if(url.indexOf('?') === -1){
return obj;
}
let first_res = url.split('?')[1];
let second_res = first_res.split('&');
for(let i in second_res){
third = second_res[i].split('=');
obj[third[0]] = third[1];
}
return obj;
}