js如何获取tree型数组中当前项的最大深度呢?consttreeData=[{key:'tree1',children:[{key:'tree2',children:[{key:'tree3',children:[{key:'tree4'}]}]},{key:'tree5'}]},{key:'tree6'},{key:'tree7'}]想获得的结果console.log(getMaxDepthByKey('tree1',treeData))结果为3console.log(getMaxDepthByKey('tree2',treeData))结果为2console.log(getMaxDepthByKey('tree3',treeData))结果为1console.log(getMaxDepthByKey('tree4',treeData))结果为0console.log(getMaxDepthByKey('tree5',treeData))结果为0console.log(getMaxDepthByKey('tree6',treeData))结果为0console.log(getMaxDepthByKey('tree7',treeData))结果为0
牧羊人nacy
Helenr
相关分类