function getUrlParams(name) {
let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
let param = window.location.search.substr(1).match(reg);
return param && decodeURIComponent(param[2])
}
原文:https://www.cnblogs.com/xingguozhiming/p/13779383.html