页面跳转的时候,地址栏往往携带了很多参数,拿到地址栏的参数对当前页面做处理,
这里是封装的方法
相关文档:https://www.runoob.com/jsref/obj-location.html
GetQueryValue(queryName) {
var query = decodeURI(window.location.search.substring(1));
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == queryName) {
return pair[1];
}
}
return null;
},
使用
this.publicid
//this.GetQueryValue('参数名')
this.publicid = this.GetQueryValue('id');