请问如下需求如何实现:
const data = { id: '1', children: [{ id: '11', children: [{ id: '111' }, { id: '112', children: [] } ] }, { id: '12', children: [{ id: '121', children: [{ id: '1211', children: [] }] }] } ] } getPath(data, '112') // ==> ['1','11','112'] getPath(data, '1211') // ==> ['1','12','121','1211']
相关分类