1 formatTreeData(checkNodes){ 2 var map = {}, 3 targetData = []; 4 checkNodes.forEach(item => { 5 if (!map[item.groupKey]) { 6 targetData.push({ 7 value: item.groupKey, 8 label:item.groupName, 9 children: [item] 10 }); 11 map[item.groupKey] = item; 12 } else { 13 for (var j = 0; j < targetData.length; j++) { 14 var dj = targetData[j]; 15 if (dj.value === item.groupKey) { 16 dj.children.push(item); 17 break; 18 } 19 } 20 } 21 }) 22 return targetData 23 },View Code
标签:map,groupKey,二维,item,json,键值,var,targetData From: https://www.cnblogs.com/cherylgi/p/17320802.html