• vue递归组件


    父组件

    1. <script setup lang="ts">
    2. import { reactive } from "vue";
    3. import treeVue from "./tree.vue";
    4. interface Tree {
    5. name: string,
    6. checked: boolean,
    7. children?: Tree[]
    8. }
    9. const treeData = reactive<Tree[]>([
    10. {
    11. name: "1",
    12. checked: false,
    13. children: [
    14. {
    15. name: "1-1",
    16. checked: false,
    17. },
    18. {
    19. name: "1-2",
    20. checked: true,
    21. },
    22. ],
    23. },
    24. {
    25. name: "2",
    26. checked: false,
    27. },
    28. {
    29. name: "3",
    30. checked: false,
    31. children: [
    32. {
    33. name: "3-1",
    34. checked: false,
    35. children: [
    36. {
    37. name: "3-1-1",
    38. checked: false,
    39. },
    40. {
    41. name: "3-1-2",
    42. checked: false,
    43. },
    44. ],
    45. },
    46. {
    47. name: "3-2",
    48. checked: false,
    49. },
    50. ],
    51. },
    52. ]);
    53. script>
    54. <style scoped>
    55. style>

    子组件