js获取url 参数方法封装
// 获取url 参数
getUrlParam(params) {
let url = location.href;
url = url.replace("?", "?&").split("&");
let re = "";
for (let i = 1; i < url.length; i++) {
if (url[i].indexOf(params + "=") == 0) {
re = url[i].replace(params + "=", "");
if (re.indexOf("#") !== -1) {
re = re.split("#")[0];
}
}
}
return re;
},
访问地址:http://localhost:8080/?distinctID=1650719397652-561899-0d59a2970059e6-25397785&parmesData=549288499719852032#/
直接页面上调用:this.getUrlParam(‘distinctID’)