Commit 173f1c00773c8cfedd3f4c02b02942f1629fd864

Authored by Rijn
1 parent f3c6cd68

skip checking children if it was empty

Showing 2 changed files with 3 additions and 2 deletions   Show diff stats
examples/routers/tree.vue
... ... @@ -29,7 +29,8 @@
29 29 },
30 30 {
31 31 title: 'child2',
32   - id: '1-2'
  32 + id: '1-2',
  33 + children: []
33 34 }
34 35 ]
35 36 }
... ...
src/components/tree/tree.vue
... ... @@ -71,7 +71,7 @@
71 71 // init checked status
72 72 function reverseChecked(data) {
73 73 if (!data.nodeKey) data.nodeKey = key++;
74   - if (data.children) {
  74 + if (data.children && data.children.length) {
75 75 let checkedLength = 0;
76 76 data.children.forEach(node => {
77 77 if (node.children) node = reverseChecked(node);
... ...