TreeTable 树表格
本期保持 PrimeVue 4.5.5 原生 API,不二次封装。导入名 WTreeTable,与上游 Props、事件、插槽、实例方法完全一致。
交互示例
基础用法
vue
<script setup lang="ts">
import { WTreeTable, WColumn } from '@wizdomt/ui'
import { FolderIcon, FileIcon } from '@wizdomt/icons'
const nodes = [
{
key: 'docs',
data: { label: '文档' },
children: [
{ key: 'docs-1', data: { label: '工作空间' } },
{ key: 'docs-2', data: { label: '团队' } },
],
},
{
key: 'projects',
data: { label: '项目' },
children: [
{ key: 'p-1', data: { label: 'Wizdomt' } },
{ key: 'p-2', data: { label: 'Playground' } },
],
},
]
</script>
<template>
<WTreeTable :value="nodes"
><WColumn field="label" header="名称" expander
><template #body="{ node }"
><span class="docs-example-node"
><FolderIcon v-if="node.children" /><FileIcon v-else />{{ node.data.label }}</span
></template
></WColumn
></WTreeTable
>
</template>说明
- 组件名:TreeTable →
WTreeTable(后者仅为别名,WTreeTable.props等类型同源) - 来源:PrimeVue v4 TreeTable 文档
- 完整 Props、事件、Slots、Methods 以上游锁定版本类型声明为准
响应式与无障碍
组件保持 PrimeVue 原生行为。示例容器负责布局;弹出层遵循各组件的 appendTo 配置。键盘与 ARIA 行为来自原生组件,使用方需提供可访问的标签。
主题与暗色模式
通过 WizdomtUI 插件启用 Wizdomt Aura 预设。切换 .dark 选择器即可在暗色下看到本组件的对应表现。
ts
import { createApp } from 'vue'
import { WizdomtUI } from '@wizdomt/ui'
import '@wizdomt/ui/style.css'
import App from './App.vue'
createApp(App).use(WizdomtUI).mount('#app')如需修改主题色,在使用方传入 theme: { preset: definePreset(WizdomtPreset, ...) },组件本身无需变更。