Files
element-plus/docs/examples/tree/multiple-times-load.vue
Noblet Ouways c57b0cab42 refactor(components): [tree] remove ts-nocheck (#21097)
* chore: wip

* chore: wip

* chore: wip

* chore: wip

* chore: fix

* chore: fix

* chore: cleanup

* chore: fix

* fix: review

Co-authored-by: btea <2356281422@qq.com>

---------

Co-authored-by: btea <2356281422@qq.com>
2025-06-24 15:01:53 +08:00

35 lines
708 B
Vue

<template>
<el-tree style="max-width: 600px" :props="props" :load="loadNode" lazy />
</template>
<script lang="ts" setup>
import type { LoadFunction } from 'element-plus'
const props = {
label: 'name',
children: 'zones',
isLeaf: 'leaf',
}
let time = 0
const loadNode: LoadFunction = (node, resolve, reject) => {
if (node.level === 0) {
return resolve([{ name: 'region' }])
}
time++
if (node.level >= 1) {
setTimeout(() => {
if (time > 3) {
return resolve([
{ name: 'zone1', leaf: true },
{ name: 'zone2', leaf: true },
{ name: 'zone3', leaf: true },
])
} else {
return reject()
}
}, 3000)
}
}
</script>