Yansen 2 anos atrás
pai
commit
7b8af96149
1 arquivos alterados com 3 adições e 2 exclusões
  1. 3
    2
      src/utils/array.js

+ 3
- 2
src/utils/array.js Ver arquivo

@@ -21,14 +21,15 @@ export function arr2Tree(arr = [], parent = 'parentId', key = 'key', rootId = '-
21 21
   // 挂载父子节点
22 22
   const tree = [];
23 23
   for (let item of arr) {
24
+    const node = dict[item[key]];
24 25
     const parentNodeId = item[parent];
25 26
 
26 27
     if (parentNodeId === rootId) {
27
-      tree.push(dict[item[key]]);
28
+      tree.push(node);
28 29
     } else {
29 30
       const parentNode = dict[parentNodeId];
30 31
       if (parentNode) {
31
-        parentNode.children.push(item);
32
+        parentNode.children.push(node);
32 33
       }
33 34
     }
34 35
   }