lazy.vue 657 B

1234567891011121314151617181920212223242526272829303132333435
  1. <template>
  2. <el-tree-select v-model="value" lazy :load="load" :props="props" />
  3. </template>
  4. <script lang="ts" setup>
  5. import { ref } from 'vue'
  6. const value = ref()
  7. const props = {
  8. label: 'label',
  9. children: 'children',
  10. isLeaf: 'isLeaf',
  11. }
  12. let id = 0
  13. const load = (node, resolve) => {
  14. if (node.isLeaf) return resolve([])
  15. setTimeout(() => {
  16. resolve([
  17. {
  18. value: ++id,
  19. label: `lazy load node${id}`,
  20. },
  21. {
  22. value: ++id,
  23. label: `lazy load node${id}`,
  24. isLeaf: true,
  25. },
  26. ])
  27. }, 400)
  28. }
  29. </script>