mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-14 10:00:58 +08:00

* style(eslint-config): add rules to restrict the imports of element-plus * chore: added validation for tsx files * chore: revert the shell
46 lines
696 B
Vue
46 lines
696 B
Vue
<template>
|
|
<el-tree
|
|
style="max-width: 600px"
|
|
:props="props"
|
|
:load="loadNode"
|
|
lazy
|
|
show-checkbox
|
|
/>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import type { LoadFunction } from 'element-plus'
|
|
|
|
interface Tree {
|
|
name: string
|
|
leaf?: boolean
|
|
}
|
|
|
|
const props = {
|
|
label: 'name',
|
|
children: 'zones',
|
|
isLeaf: 'leaf',
|
|
}
|
|
|
|
const loadNode: LoadFunction = (node, resolve) => {
|
|
if (node.level === 0) {
|
|
return resolve([{ name: 'region' }])
|
|
}
|
|
if (node.level > 1) return resolve([])
|
|
|
|
setTimeout(() => {
|
|
const data: Tree[] = [
|
|
{
|
|
name: 'leaf',
|
|
leaf: true,
|
|
},
|
|
{
|
|
name: 'zone',
|
|
},
|
|
]
|
|
|
|
resolve(data)
|
|
}, 500)
|
|
}
|
|
</script>
|