var getUrlParam = function(name){
var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)"),
r = window.location.search.substr(1).match(reg);
console.log(window.location.search)
if (r!=null){
return unescape(r[2]);
}else {
return null;
}
}
// http://localhost:8000?param=1
console.log( getUrlParam("param")) // 输出1 字符串型
使用原生方法获取地址栏参数
最新推荐文章于 2023-03-20 08:00:00 发布