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 18 v-if="!item.isLeaf"
19 19 v-show="item.expand"
20 20 :class="expandCls(item)"
21   - :value="item.children"
22   - :name="item.name+'.'+index"
  21 + :data="item.children"
  22 + :name="name+'.'+index"
23 23 :multiple="multiple"
24 24 :show-checkbox="showCheckbox"></Tree>
25 25 </transition>
... ... @@ -39,7 +39,7 @@
39 39 components: { Icon, Checkbox },
40 40 mixins: [ Emitter ],
41 41 props: {
42   - value: {
  42 + data: {
43 43 type: Array,
44 44 default () {
45 45 return [];
... ... @@ -66,8 +66,7 @@
66 66 },
67 67 data () {
68 68 return {
69   - prefixCls: prefixCls,
70   - data: this.value
  69 + prefixCls: prefixCls
71 70 };
72 71 },
73 72 computed: {
... ... @@ -80,9 +79,6 @@
80 79 }
81 80 },
82 81 watch: {
83   - value (val) {
84   - this.data = val;
85   - },
86 82 data () {
87 83 if (this.name === '0') {
88 84 this.setKey();
... ...
test/routers/tree.vue
1 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 6 </template>
4 7 <script>
5 8 export default {
... ... @@ -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 41 </script>
... ...