var urlParams = getUrlParams();
function getUrlParams(){
var url = document.URL;
let urlStr = url.split('?')[1]
let obj = {};
if (urlStr) {
let paramsArr = urlStr.split('&')
for(let i = 0,len = paramsArr.length;i < len;i++){
let arr = paramsArr[i].split('=')
obj[arr[0]] = decodeURI(arr[1]); //对 encodeURI() 函数编码过的 URI 进行解码
}
}
return obj
};
标签:arr,URL,获取,urlStr,let,split,参数,paramsArr
From: https://www.cnblogs.com/strongerPian/p/16963802.html