获取url上的参数

1
2
3
4
5
6
7
8
9
10
11
12
function getUrlParam(name) {
if (name == null) {
return name;
}
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
//return unescape(r[2]);
return r[2];
}
return null;
}

image-20200902203005919

1
console.log(getUrlParam("id"));

image-20200902203057830