使用:
getQueryVariable('type')//获取单个的参数
getQueryVariable()//获取所有参数
functiong getQueryVariable(variable){
var vars=[]
if( window.location.hash!=''){
var query0 = window.location.hash.split('?')[1];
if(query0)vars = query0.split("&");
}else{
var query = window.location.search.substring(1);
if(query)vars = query.split("&");
}
let queryObject={}
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
queryObject[pair[0]]=pair[1]
}
if(variable){
if(queryObject[variable] && queryObject[variable]!=''){
return queryObject[variable]
}else{
return false;
}
}else{
return queryObject
}
}