function GetQueryString (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
使用
http://127.0.0.1:5500/index.html?name=00999&isShow=true
const name = GetQueryString('name')
const isShow = GetQueryString('isShow')
console.log(typeof isShow, isShow) //string true
但是需要注意的是,获取到的参数值全部为字符串类型