JavaScript中树形数据转数组的解决方案(利用递归)
代码为:
//树形数据
const treeData = [{
id: 1,
name: '技术部',
children: [{
pid: 1,
id: 11,
name: '前端技术部',
children: [{
pid: 11,
id: 111,
name: '小程序技术部'
}, {
pid: 11,
id: 112,
name: 'Vue技术部'
}]
}, {
pid: 1,
id: 12,
name: 'Java技术部'
}, {
pid: 1,
id: 13,
name: 'Python技术部'
}]
}, {
id: 2,
name: '运营部',
children: [{
pid: 2,
id