vuejs-challenges icon indicating copy to clipboard operation
vuejs-challenges copied to clipboard

208 - 树组件

Open kalu5 opened this issue 2 years ago • 0 comments

// 你的答案
<script setup lang="ts">
interface TreeData {
  key: string
  title: string
  children: TreeData[]
}
defineProps<{data: TreeData[]}>()
function CommonTree () {
  return 
}
</script>

<template>
  <!-- do something.... -->
  <ul>
    <li v-for="parent in data" :key="parent.key">
      {{ parent.title }}
      <template v-if="parent.children && parent.children.length">
        <TreeComponent :data="parent.children" />
      </template>
    </li>
  </ul>
</template>

kalu5 avatar Sep 19 '22 02:09 kalu5