Commit 2e84df449ae433e8176ecd76f024cd097ba864f6
1 parent
e6e97035
fixed Tree key bug under Vue 2.4.1
Showing
2 changed files
with
5 additions
and
2 deletions
Show diff stats
src/components/tree/node.vue
src/components/tree/tree.vue
... | ... | @@ -2,7 +2,7 @@ |
2 | 2 | <div :class="prefixCls"> |
3 | 3 | <Tree-node |
4 | 4 | v-for="item in data" |
5 | - :key="item" | |
5 | + :key="item.nodeKey" | |
6 | 6 | :data="item" |
7 | 7 | visible |
8 | 8 | :multiple="multiple" |
... | ... | @@ -19,6 +19,8 @@ |
19 | 19 | |
20 | 20 | const prefixCls = 'ivu-tree'; |
21 | 21 | |
22 | + let key = 1; | |
23 | + | |
22 | 24 | export default { |
23 | 25 | name: 'Tree', |
24 | 26 | mixins: [ Emitter, Locale ], |
... | ... | @@ -68,6 +70,7 @@ |
68 | 70 | updateData (isInit = true) { |
69 | 71 | // init checked status |
70 | 72 | function reverseChecked(data) { |
73 | + if (!data.nodeKey) data.nodeKey = key++; | |
71 | 74 | if (data.children) { |
72 | 75 | let checkedLength = 0; |
73 | 76 | data.children.forEach(node => { | ... | ... |