vue2server7 7.0.3 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/test/320 +25 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue2server7",
3
- "version": "7.0.3",
3
+ "version": "7.0.4",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "nodemon --watch src --ext ts --exec \"ts-node src/app.ts\"",
package/test/320 ADDED
@@ -0,0 +1,25 @@
1
+ interface TreeNode {
2
+ value: string | number
3
+ label: string
4
+ children?: TreeNode[]
5
+ }
6
+
7
+ function findLabelByValue(
8
+ list: TreeNode[],
9
+ targetValue: string | number
10
+ ): string | null {
11
+ for (const item of list) {
12
+ // 当前节点命中
13
+ if (item.value === targetValue) {
14
+ return item.label
15
+ }
16
+
17
+ // 递归子节点
18
+ if (item.children && item.children.length) {
19
+ const result = findLabelByValue(item.children, targetValue)
20
+ if (result) return result
21
+ }
22
+ }
23
+
24
+ return null
25
+ }