获取url字符串的参数对象

话不多说直接上代码, 复制粘贴就可以用哦

queryParams: function (url) {var decode,i,key,len1,o,oldValue,pair,param,params,query,ref,value;decode = function (str) {return decodeURIComponent((str|| "").replace(/\+/g," "));};url= url.split('?')[1];if (url== undefined) url= "";query = url|| "";params = {};if (query.length> 0) {ref = query.split("&");for (i = o = 0,len1 = ref.length;o < len1;i = ++o) {param = ref[i];pair = param.split("=");key = decode(pair.shift());value = decode(pair.length? pair.join("="): null);if (params.hasOwnProperty(key)) {oldValue = params[key];if (oldValue instanceof Array) {oldValue.push(value);}else {params[key]= [oldValue,value];}}else {params[key]= value;}}}return params;},

你可能感兴趣的:(获取url字符串的参数对象)