iview/examples/routers/tree.vue

82 lines
2.7 KiB
Vue
Raw Normal View History

<template>
2019-08-29 11:42:30 +08:00
<Tree :data="data3" :load-data="loadData" show-checkbox></Tree>
</template>
<script>
2019-08-29 11:42:30 +08:00
//验证bug #6139
export default {
2017-03-03 10:35:38 +08:00
data () {
2017-02-07 11:34:00 +08:00
return {
2019-08-29 11:42:30 +08:00
data3: [
2017-03-24 20:50:13 +08:00
{
2019-08-29 11:42:30 +08:00
title: 'parent',
loading: false,
children: []
}
]
};
},
methods: {
loadData (item, callback) {
setTimeout(() => {
const isSet = Math.ceil(Math.random()*10)%2;
let data = [];
if( isSet ){
data = [
2017-04-27 13:56:58 +08:00
{
2019-08-29 11:42:30 +08:00
title: 'children-1',
loading: false,
children: []
2017-04-27 13:56:58 +08:00
}
2019-08-29 11:42:30 +08:00
];
2017-03-27 14:28:42 +08:00
}
2019-08-29 11:42:30 +08:00
callback(data);
}, 1000);
2017-10-23 11:55:35 +08:00
}
2017-02-07 11:34:00 +08:00
}
2019-08-29 11:42:30 +08:00
};
2017-10-25 22:34:58 +08:00
</script>
2019-08-29 11:42:30 +08:00
<!--<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>-->