获取页面url信息

方法:
window.location.href = prefixURL+'webstatic/messageAnalysis/datadetail.html?id=' + num + "&time=" + time+"&authKey="+this.authKey
getUrlArgs: function () {
const query = location.search.substring(1);
const pairs = query.split('&');
let args = {};
let pos;
let idx;
let argname;
let val;
for (var i = 0; i < pairs.length; i++) {
pos = pairs[i];
idx = pos.indexOf('=');
if (idx == -1) continue;
argname = pos.substring(0, idx);
val = decodeURIComponent(pos.substring(idx + 1));
args[argname] = val;
}
return args;
},
 
方法调用:
获取url后面对应的参数名称
 
let urlArgs = globalFunc.getUrlArgs();
this.authKey = urlArgs.authKey;
 

猜你喜欢

转载自www.cnblogs.com/suixinYB/p/10112010.html