1.获取地址栏参数
getParamsUrl(name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
if (window.location.hash.indexOf("?") < 0) {
return null;
}
let r = window.location.hash.split("?")[1].match(reg);
if (r != null) return decodeURIComponent(r[2]);
return null;
}
使用:this.xxx=this.getParamsUrl(‘xxx’)
2.获取地址栏带#的参数
getQueryString(name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
if (window.location.hash.indexOf("?") < 0) {
return null;
}
let r = window.location.hash.split("?")[1].match(reg);
if (r != null) return decodeURIComponent(r[2]);
return null;
}