This commit is contained in:
梁灏 2017-04-27 13:56:58 +08:00
parent 05e2dda017
commit 69a10b78f7
3 changed files with 138 additions and 49 deletions

View file

@ -1,5 +1,5 @@
<template>
<Tree :data="baseData" @on-check-change="handleSelectChange" show-checkbox></Tree>
<Tree :data="baseData" show-checkbox @on-check-change="handleChange" ></Tree>
</template>
<script>
export default {
@ -8,55 +8,30 @@
bd: [],
baseData: [
{
title: 'parent',
id: '1-0',
expand: true,
title: 'parent 1',
children: [{
title: 'parent 1-0',
expand: true,
// disabled: true,
// checked: true,
children: [
{
title: 'leaf',
checked: true,
selected: true
},
{
title: 'leaf',
checked: false
}
]
}, {
title: 'parent 1-1',
expand: true,
checked: true,
children: [
{
title: '<span style="color: red">leaf</span>',
checked: false
}
]
}]
},
{
expand: true,
title: 'parent 1',
children: [{
title: 'parent 1-0',
expand: true,
children: [{
title: 'leaf'
}, {
title: 'leaf',
}]
}, {
title: 'parent 1-1',
expand: true,
checked: true,
children: [{
title: '<span style="color: red">leaf</span>',
}]
}]
children: [
{
title: 'child1',
id: '1-1',
expand: true,
children: [
{
title: 'child1-1-1',
id: '1-1-1'
},
{
title: 'child1-1-2',
id: '1-1-2'
}
]
},
{
title: 'child2',
id: '1-2'
}
]
}
]
}
@ -64,7 +39,18 @@
methods: {
handleSelectChange (data) {
console.log(data);
},
updateTree (data) {
data[0].children[0].checked = true;
// data[0].children[0].children[0].checked = true;
// data[0].children[0].children[1].checked = true;
},
handleChange () {
console.log(1)
}
},
mounted () {
this.updateTree(this.baseData);
}
}
</script>