update Tree

update Tree(in Vue 2,can not use this.xxx in template’s prop,just xxx)
This commit is contained in:
梁灏 2017-03-03 11:35:33 +08:00
parent e2c6ff2b67
commit 9d79a51f0d
2 changed files with 13 additions and 9 deletions

View file

@ -18,8 +18,8 @@
v-if="!item.isLeaf" v-if="!item.isLeaf"
v-show="item.expand" v-show="item.expand"
:class="expandCls(item)" :class="expandCls(item)"
:value="item.children" :data="item.children"
:name="item.name+'.'+index" :name="name+'.'+index"
:multiple="multiple" :multiple="multiple"
:show-checkbox="showCheckbox"></Tree> :show-checkbox="showCheckbox"></Tree>
</transition> </transition>
@ -39,7 +39,7 @@
components: { Icon, Checkbox }, components: { Icon, Checkbox },
mixins: [ Emitter ], mixins: [ Emitter ],
props: { props: {
value: { data: {
type: Array, type: Array,
default () { default () {
return []; return [];
@ -66,8 +66,7 @@
}, },
data () { data () {
return { return {
prefixCls: prefixCls, prefixCls: prefixCls
data: this.value
}; };
}, },
computed: { computed: {
@ -80,9 +79,6 @@
} }
}, },
watch: { watch: {
value (val) {
this.data = val;
},
data () { data () {
if (this.name === '0') { if (this.name === '0') {
this.setKey(); this.setKey();

View file

@ -1,5 +1,8 @@
<template> <template>
<Tree v-model="baseData" show-checkbox></Tree> <div>
<Tree :data="baseData" show-checkbox></Tree>
<div @click="c">change</div>
</div>
</template> </template>
<script> <script>
export default { export default {
@ -28,6 +31,11 @@
}] }]
}] }]
} }
},
methods: {
c () {
this.baseData[0].expand = false;
}
} }
} }
</script> </script>