Skip to content

Commit ea0540f

Browse files
committed
docs: update treeDeep
1 parent 1ec9acf commit ea0540f

File tree

1 file changed

+94
-6
lines changed

1 file changed

+94
-6
lines changed

docs/treeDeep.md

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,101 @@
1-
# treeDeep
2-
3-
get max deep of tree
4-
5-
## 调用
1+
# 树深度
62

73
```js
84
treeDeep(tree, [options], [deep = 1])
95
```
106

7+
获取树状数据结构的最大树深度。
8+
9+
## 参数
10+
11+
| 参数 | 类型 | 默认 | 说明 |
12+
| --------- | -------- | ---- | -------------------------------- |
13+
| `tree` | `tree` | | [树状结构数据](./param.md#tree) |
14+
| `options` | `object` | | [配置选项](./param.md#options) |
15+
| `deep` | `number` | `1` | 初始深度,以此基础累加到最大深度 |
16+
1117
## 返回
1218

13-
int
19+
| 参数 | 类型 | 说明 |
20+
| ---- | -------- | ---------- |
21+
| * | `number` | 最大树深度 |
22+
23+
## 示例
24+
25+
::: code-group
26+
```js [调用]
27+
import { treeDeep } from '@axolo/tree-array'
28+
29+
const tree = [{
30+
id: 'home',
31+
path: '/home',
32+
parentId: null
33+
}, {
34+
id: 'chart',
35+
path: '/chart',
36+
parentId: null,
37+
children: [{
38+
id: 'chartIndex',
39+
path: '/chart/index',
40+
parentId: 'chart',
41+
children: [{
42+
id: 'chartIndexTop',
43+
path: '/chart/index/top',
44+
parentId: 'chartIndex'
45+
}, {
46+
id: 'chartIndexActive',
47+
path: '/chart/index/active',
48+
parentId: 'chartIndex',
49+
children: [{
50+
id: 'chartIndexActiveMy',
51+
path: '/chart/index/active/my',
52+
parentId: 'chartIndexActive'
53+
}]
54+
}]
55+
}, {
56+
id: 'chartReview',
57+
path: '/chart/review',
58+
parentId: 'chart'
59+
}, {
60+
id: 'chartProject',
61+
path: '/chart/project',
62+
parentId: 'chart',
63+
children: [{
64+
id: 'chartProjectYou',
65+
path: '/chart/project/you',
66+
parentId: 'chartProject',
67+
test: true
68+
}, {
69+
id: 'chartProjectMy',
70+
path: '/chart/project/my',
71+
parentId: 'chartProject',
72+
children: [{
73+
id: 'chartProjectMyOne',
74+
path: '/chart/project/my/one',
75+
parentId: 'chartProjectMy'
76+
}, {
77+
id: 'chartProjectMyTwo',
78+
path: '/chart/project/my/two',
79+
parentId: 'chartProjectMy'
80+
}]
81+
}]
82+
}]
83+
}, {
84+
id: 'smile',
85+
path: '/smile',
86+
parentId: null,
87+
children: [{
88+
id: 'smileIndex',
89+
path: '/smile/index',
90+
parentId: 'smile',
91+
test: true
92+
}]
93+
}]
94+
95+
treeDeep(tree) // 4
96+
```
97+
98+
```json [结果]
99+
4
100+
```
101+
:::

0 commit comments

Comments
 (0)