标签:pre foreach UNC turn 查询 indexof reac query dex
var util = {};
/**
* 对象转为查询字符串
* @type object
* */
util.toQueryString = function(obj) {
var str = "";
for (let n in obj) {
str += n + "=" + obj[n] + "&";
}
str = str.substring(0, str.length - 1);
return str;
}
/**
* 查询字符串转为对象
* */
util.parseObject = function(url){
var obj = {};
if(url.indexOf(‘?‘)!==-1){
var url = url.substring(url.indexOf(‘?‘)+1);
}else{
return {};
}
var arr = url.split(‘&‘);
arr.forEach(function(val){
var brr = val.split(‘=‘);
obj[brr[0]] = brr[1];
});
return obj;
}
标签:pre foreach UNC turn 查询 indexof reac query dex
原文地址:https://www.cnblogs.com/koala0521/p/9210845.html