Skip to content

Commit 4165925

Browse files
committed
docs: [removeTreeData] 增加示例
1 parent 5844ff3 commit 4165925

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/object/base.ts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,48 @@ export function removeEmptyValues(obj: any, exclude?: excludeOptions) {
169169
}
170170

171171
/**
172-
* Remove tree data that matches the specified value
172+
* Remove `tree data` that matches the specified value
173173
* 去除树状数据中指定的数据
174174
*
175+
* @category Base
175176
* @param treeData 树状数据
176177
* @param matchFunction 匹配函数
177-
* @returns 去除后的树状数据
178+
* @returns Array 处理好的值
179+
* @example
180+
* ```
181+
*const treeData = [
182+
* {
183+
* id: 1,
184+
* name: "A",
185+
* children: [
186+
* {
187+
* id: 2,
188+
* name: "B",
189+
* children: [
190+
* {
191+
* id: 3,
192+
* name: "C",
193+
* children: [],
194+
* },
195+
* ],
196+
* },
197+
* {
198+
* id: 4,
199+
* name: "D",
200+
* children: [],
201+
* },
202+
* ],
203+
* },
204+
* {
205+
* id: 5,
206+
* name: "E",
207+
* children: [],
208+
* },
209+
*];
210+
*const matchFunction = (item:any) => item.id === 3;
211+
*const newTreeData = removeTreeData(treeData, matchFunction);
212+
*
213+
* ```
178214
*/
179215
export function removeTreeData(
180216
treeData: any[],

0 commit comments

Comments
 (0)