Commit 2e84df449ae433e8176ecd76f024cd097ba864f6

Authored by 梁灏
1 parent e6e97035

fixed Tree key bug under Vue 2.4.1

src/components/tree/node.vue
... ... @@ -14,7 +14,7 @@
14 14 <span :class="titleClasses" v-html="data.title" @click="handleSelect"></span>
15 15 <Tree-node
16 16 v-for="item in data.children"
17   - :key="item"
  17 + :key="item.nodeKey"
18 18 :data="item"
19 19 :visible="data.expand"
20 20 :multiple="multiple"
... ...
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 => {
... ...