慕码人8056858
我总是把这当成一条线。现在帕拉姆有了瓦尔斯:params={};location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){params[k]=v})多线:var params={};window.location.search .replace(/[?&]+([^=&]+)=([^&]*)/gi, function(str,key,value) {
params[key] = value;
});作为一种功能function getSearchParams(k){
var p={};
location.search.replace(/[?&]+([^=&]+)=([^&]*)/gi,function(s,k,v){p[k]=v})
return k?p[k]:p;}你可以把它用作:getSearchParams() //returns {key1:val1, key2:val2}或getSearchParams("key1") //returns val1