Commit 9d79a51f0d2f7e30f5db606fcadf52c9b275c606

Authored by 梁灏
1 parent e2c6ff2b

update Tree

update Tree(in Vue 2,can not use this.xxx in template’s prop,just xxx)
Showing 2 changed files with 13 additions and 9 deletions   Show diff stats
src/components/tree/tree.vue
@@ -18,8 +18,8 @@ @@ -18,8 +18,8 @@
18 v-if="!item.isLeaf" 18 v-if="!item.isLeaf"
19 v-show="item.expand" 19 v-show="item.expand"
20 :class="expandCls(item)" 20 :class="expandCls(item)"
21 - :value="item.children"  
22 - :name="item.name+'.'+index" 21 + :data="item.children"
  22 + :name="name+'.'+index"
23 :multiple="multiple" 23 :multiple="multiple"
24 :show-checkbox="showCheckbox"></Tree> 24 :show-checkbox="showCheckbox"></Tree>
25 </transition> 25 </transition>
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 components: { Icon, Checkbox }, 39 components: { Icon, Checkbox },
40 mixins: [ Emitter ], 40 mixins: [ Emitter ],
41 props: { 41 props: {
42 - value: { 42 + data: {
43 type: Array, 43 type: Array,
44 default () { 44 default () {
45 return []; 45 return [];
@@ -66,8 +66,7 @@ @@ -66,8 +66,7 @@
66 }, 66 },
67 data () { 67 data () {
68 return { 68 return {
69 - prefixCls: prefixCls,  
70 - data: this.value 69 + prefixCls: prefixCls
71 }; 70 };
72 }, 71 },
73 computed: { 72 computed: {
@@ -80,9 +79,6 @@ @@ -80,9 +79,6 @@
80 } 79 }
81 }, 80 },
82 watch: { 81 watch: {
83 - value (val) {  
84 - this.data = val;  
85 - },  
86 data () { 82 data () {
87 if (this.name === '0') { 83 if (this.name === '0') {
88 this.setKey(); 84 this.setKey();
test/routers/tree.vue
1 <template> 1 <template>
2 - <Tree v-model="baseData" show-checkbox></Tree> 2 + <div>
  3 + <Tree :data="baseData" show-checkbox></Tree>
  4 + <div @click="c">change</div>
  5 + </div>
3 </template> 6 </template>
4 <script> 7 <script>
5 export default { 8 export default {
@@ -28,6 +31,11 @@ @@ -28,6 +31,11 @@
28 }] 31 }]
29 }] 32 }]
30 } 33 }
  34 + },
  35 + methods: {
  36 + c () {
  37 + this.baseData[0].expand = false;
  38 + }
31 } 39 }
32 } 40 }
33 </script> 41 </script>