前端get请求url拼接多项参数方法(把对象或对象下的数组拼接为url参数)
前端get请求url拼接多项参数方法
var toString = ""; for (var key in data) { if(!data[key]){ delete data.key }else{ var obj = data[key]; if (Array.isArray(obj)) { var arrayString = obj.join(","); toString += key + "=" + arrayString + "&"; } else { toString += key + "=" + data[key] + "&"; } } } toString.substring(0, toString.length - 1).replace(/$/, "");