/**
* 获取url参数
* @param arg
* @returns {[]}
*/
export const getUrlParams = (arg) => {
try {
let url = arg || window.location.toString();
let urlParams = [];
let paramPos = url.lastIndexOf("?");
if (paramPos != -1) {
let anchorPos = url.lastIndexOf("#")
//let paramAry = (url.substr(url.indexOf("?") + 1)).split('&')
let paramAry = ((paramPos < anchorPos) ? url.substring(paramPos + 1, anchorPos) : url.substring(paramPos + 1)).split("&")
for (let i = 0; i < paramAry.length; i++) {
urlParams[paramAry[i].split("=")[0]] = unescape(paramAry[i].split("=")[1])
}
}
console.log(urlParams)
return urlParams;
}
catch (e)
{
console.log(e);
return {};
}
}
07-29
645
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-01
289
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-08
1666
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-06
3645
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
02-10
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交