parent
e61df0d038
commit
96bd19e9bf
2 changed files with 75 additions and 33 deletions
|
@ -1,43 +1,81 @@
|
||||||
<template>
|
<template>
|
||||||
<Tree :data="data2" check-directly show-checkbox></Tree>
|
<Tree :data="data3" :load-data="loadData" show-checkbox></Tree>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
//验证bug #6139
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
data2: [
|
data3: [
|
||||||
{
|
{
|
||||||
title: 'parent 1',
|
title: 'parent',
|
||||||
expand: true,
|
loading: false,
|
||||||
children: [
|
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'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
};
|
||||||
|
},
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</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>-->
|
||||||
|
|
|
@ -71,7 +71,9 @@
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
prefixCls: prefixCls,
|
prefixCls: prefixCls,
|
||||||
appearByClickArrow: false
|
appearByClickArrow: false,
|
||||||
|
// #6139
|
||||||
|
loadingChildrenState : true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -105,7 +107,7 @@
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
showArrow () {
|
showArrow () {
|
||||||
return (this.data[this.childrenKey] && this.data[this.childrenKey].length) || ('loading' in this.data && !this.data.loading);
|
return (this.data[this.childrenKey] && this.data[this.childrenKey].length) || ('loading' in this.data && !this.data.loading && this.loadingChildrenState);
|
||||||
},
|
},
|
||||||
showLoading () {
|
showLoading () {
|
||||||
return 'loading' in this.data && this.data.loading;
|
return 'loading' in this.data && this.data.loading;
|
||||||
|
@ -188,6 +190,8 @@
|
||||||
if (children.length) {
|
if (children.length) {
|
||||||
this.$set(this.data, this.childrenKey, children);
|
this.$set(this.data, this.childrenKey, children);
|
||||||
this.$nextTick(() => this.handleExpand());
|
this.$nextTick(() => this.handleExpand());
|
||||||
|
}else{
|
||||||
|
this.loadingChildrenState = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue