需求:用最优性能的方法将嵌套数组转化为一维数组。var data = [ { id: '1', title: 'A1', child: [ { id: '4', title: 'B1' } ] }, { id: '2', title: 'A2', child: [ { id: '5', title: 'B2', child: [ { id: '7', title: 'C1', child: [ { id: '8', title: 'D1' } ] } ] }, { id: '6', title: 'B3' } ] }, { id: '3', title: 'A3' }]// 结果应该为:// [{id:'1',title:'A1'},{id:'4',title:'B1'},{id:'2',title:'A2'},{id:'5',title:'B2'}...]请各路大侠赐教!
添加回答
举报
0/150
提交
取消