This commit is contained in:
mo.duan 2019-10-09 16:41:00 +08:00
parent a6068736cb
commit b93725bbb9
2 changed files with 51 additions and 71 deletions

View file

@ -1,81 +1,55 @@
<template>
<Tree :data="data3" :load-data="loadData" show-checkbox></Tree>
<div>
<Tree ref="treeRef" :data="data4" show-checkbox multiple></Tree>
<Button @click="get">
get
</Button>
</div>
</template>
<script>
//bug #6139
export default {
data () {
return {
data3: [
data4: [
{
title: 'parent',
loading: false,
children: []
title: 'parent 1',
expand: true,
children: [
{
title: 'parent 1-1',
expand: true,
children: [
{
title: 'leaf 1-1-1',
checked : false,
disabled: true
},
{
title: 'leaf 1-1-2'
}
]
},
{
title: 'parent 1-2',
expand: true,
children: [
{
title: 'leaf 1-2-1',
},
{
title: 'leaf 1-2-1'
}
]
}
]
}
]
};
}
},
methods: {
loadData (item, callback) {
setTimeout(() => {
const isSet = Math.ceil(Math.random()*10)%2;
let data = [];
if( isSet ){
data = [
{
title: 'children-1',
loading: false,
children: []
}
];
}
callback(data);
}, 1000);
get(){
console.log(this.$refs.treeRef.getCheckedNodes())
}
}
};
}
</script>
<!--<template>-->
<!-- <Tree :data="data2" check-directly show-checkbox></Tree>-->
<!--</template>-->
<!--<script>-->
<!-- export default {-->
<!-- data () {-->
<!-- return {-->
<!-- data2: [-->
<!-- {-->
<!-- title: 'parent 1',-->
<!-- expand: true,-->
<!-- children: [-->
<!-- {-->
<!-- title: 'parent 1-1',-->
<!-- expand: true,-->
<!-- children: [-->
<!-- {-->
<!-- title: 'leaf 1-1-1'-->
<!-- },-->
<!-- {-->
<!-- title: 'leaf 1-1-2'-->
<!-- }-->
<!-- ]-->
<!-- },-->
<!-- {-->
<!-- title: 'parent 1-2',-->
<!-- expand: true,-->
<!-- children: [-->
<!-- {-->
<!-- title: 'leaf 1-2-1'-->
<!-- },-->
<!-- {-->
<!-- title: 'leaf 1-2-1'-->
<!-- }-->
<!-- ]-->
<!-- }-->
<!-- ]-->
<!-- }-->
<!-- ]-->
<!-- }-->
<!-- }-->
<!-- }-->
<!--</script>-->