function formatData(tempObj){ let bigArr = []; for(let p in tempObj){ let tempArrForeach1 = [] for(let key in tempObj[p]){ //数组层 tempArrForeach1.push(arrToObj(tempObj[p][key])); } bigArr.push((tempArrForeach1)) } return bigArr; function arrToObj(arr=[]){ var outObj = {}; //认为arr数组内Element所有字段一致 Object.keys(arr[0]).forEach(key=>{ var arrChilds = Array.from(new Set((arr.map(v=>v[key])+'').split(','))); if(arrChilds.length>1){ outObj[key] = arrChilds; }else if(arrChilds.length==1){ outObj[key] = arrChilds[0] } }); return outObj } }