function getParams(url) {
let theRequest = new Object();
if (!url)
url = location.href;
if (url.indexOf("?") !== -1)
{
let str = url.substr(url.indexOf("?") + 1) + "&";
let strs = str.split("&");
for (let i = 0; i < strs.length - 1; i++)
{
let key = strs[i].substring(0, strs[i].indexOf("="));
let val = strs[i].substring(strs[i].indexOf("=") + 1);
theRequest[key] = val;
}
}
return theRequest;
}
//调用方法为 let getFunPatams = getParams();
//获取地址栏上的userName
let getFunPatams = getParams();
let getUserName = getFunPatams.userName;
console.log(getUserName)