let news = [{
"title": "根目录",
"id": 0,
"children": [{
"title": "test-yl",
"id": 1,
"children": [{
"title": "通abtest指标统计",
"id": 5,
"children": [],
},
{
"title": "test-yl2",
"id": 6,
"children": [{
"title": "[搜狗APP]无线黑名单数据",
"id": 7,
"children": [],
}],
}
],
},
{
"title": "是农村进口设备v",
"id": 2,
"children": [{
"title": "你还欧水防护等级啊大家撒 ",
"id": 975,
"children": [],
}],
},
{
"title": "你的看到出发点卡萨",
"id": 888,
"children": [{
"title": "是名乘客辽宁省 ",
"id": 666,
"children": [],
}],
}
],
}]
let old = [{
"title": "根目录",
"id": 0,
"children": [{
"title": "test-yl",
"id": 1,
"children": [{
"title": "test-yl2",
"id": 6,
"children": [{
"title": "答复您尽快吧百年大计哦",
"id": 999,
"children": [],
}],
}],
},
{
"title": "是农村进口设备v",
"id": 2,
"children": [{
"title": "VB吃烧烤不过 ",
"id": 898,
"children": [{
"title": "程度不会卡两个",
"id": 456,
"children": [{
"title": "第三课发货大吉 ",
"id": 987,
"children": [],
}],
}, ],
}],
},
{
"title": "你的看到出发点卡萨",
"id": 888,
"children": [{
"title": "是名乘客辽宁省 ",
"id": 666,
"children": [],
}],
}
],
}]
// 合并数组,找到对应的父节点加进去,id是唯一的
// 合并结果
// [{
// "title": "根目录",
// "id": 0,
// "children": [{
// "title": "testyl",
// "id": 1,
// "children": [{
// "title": "通abtest指标统计",
// "id": 5,
// "children": [],
// },
// {
// "title": "test-yl2",
// "id": 6,
// "children": [{
// "title": "答复您尽快吧百年大计哦",
// "id": 999,
// "children": [],
// },
// {
// "title": "[搜狗APP]无线黑名单数据",
// "id": 7,
// "children": [],
// }
// ],
// }
// ],
// },
// {
// "title": "是农村进口设备v",
// "id": 2,
// "children": [{
// "title": "你还欧水防护等级啊大家撒 ",
// "id": 975,
// "children": [],
// }, {
// "title": "VB吃烧烤不过 ",
// "id": 898,
// "children": [{
// "title": "程度不会卡两个",
// "id": 456,
// "children": [{
// "title": "第三课发货大吉 ",
// "id": 987,
// "children": [],
// }],
// }, ],
// }],
// },
// {
// "title": "你的看到出发点卡萨",
// "id": 888,
// "children": [{
// "title": "是名乘客辽宁省 ",
// "id": 666,
// "children": [],
// }],
// }
// ],
// }]
用js怎么实现~~~