constdata={name:'A',child:[{name:'AB',child:[{name:'AABA'},{name:'AABB'}]},{name:'AC',child:[{name:'AACA'},{name:'AACB'}]}]}//请自行封装一个findPath的函数,实现如下效果//调用示例findPath('AABB');//["A","AB","AABB"]findPath('AABA');//["A","AB","AABA"]findPath('AACB');//["A","AC","AACB"]findPath('AC');//["A","AC"]findPath('AACA');//["A","AC","AACA"]
2 回答
手掌心
TA贡献1942条经验 获得超3个赞
constdata={'A':{name:'A',parent:undefined},'AB':{name:'AB',parent:'A'},'AABA':{name:'AABA',parent:'AB'},...}我会先将数据转换成上面的结构缓存下来这样后面取的时候就简单多了
添加回答
举报
0/150
提交
取消