default-state.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <el-tree :data="data" show-checkbox node-key="id" :default-expanded-keys="[2, 3]" :default-checked-keys="[5]" :props="defaultProps" />
  3. </template>
  4. <script lang="ts" setup>
  5. const defaultProps = {
  6. children: 'children',
  7. label: 'label',
  8. }
  9. const data = [
  10. {
  11. id: 1,
  12. label: 'Level one 1',
  13. children: [
  14. {
  15. id: 4,
  16. label: 'Level two 1-1',
  17. children: [
  18. {
  19. id: 9,
  20. label: 'Level three 1-1-1',
  21. },
  22. {
  23. id: 10,
  24. label: 'Level three 1-1-2',
  25. },
  26. ],
  27. },
  28. ],
  29. },
  30. {
  31. id: 2,
  32. label: 'Level one 2',
  33. children: [
  34. {
  35. id: 5,
  36. label: 'Level two 2-1',
  37. },
  38. {
  39. id: 6,
  40. label: 'Level two 2-2',
  41. },
  42. ],
  43. },
  44. {
  45. id: 3,
  46. label: 'Level one 3',
  47. children: [
  48. {
  49. id: 7,
  50. label: 'Level two 3-1',
  51. },
  52. {
  53. id: 8,
  54. label: 'Level two 3-2',
  55. },
  56. ],
  57. },
  58. ]
  59. </script>