123456789101112131415161718192021222324 |
- <template>
- <el-cascader :props="props" />
- </template>
- <script lang="ts" setup>
- import type { CascaderProps } from 'element-plus'
- let id = 0
- const props: CascaderProps = {
- lazy: true,
- lazyLoad(node, resolve) {
- const { level } = node
- setTimeout(() => {
- const nodes = Array.from({ length: level + 1 }).map((item) => ({
- value: ++id,
- label: `Option - ${id}`,
- leaf: level >= 2,
- }))
- // Invoke `resolve` callback to return the child nodes data and indicate the loading is finished.
- resolve(nodes)
- }, 1000)
- },
- }
- </script>
|