js 獲取地址欄參數(shù)的方法:
function getUrlParam(name){
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
比如當(dāng)前地址為:http://baidu.com/?id=100&name=sanfeng
let id = getUrlParam('id');
let name = getUrlParam('name');
console.log(id) //100
console.log(id) // sanfeng