Files
workspace/code/g3soft-libs/docs/examples/tree/basic.vue
T
2026-10-08 22:38:34 +08:00

28 lines
813 B
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
// 最基础:treeData 是嵌套结构,默认按 { key, title, children } 取值
import { ref } from 'vue'
import { G3Tree, type TreeNodeData } from '@g3soft/ui'
const treeData: TreeNodeData[] = [
{
key: 'design',
title: '设计',
children: [
{ key: 'design/ui', title: 'UI 规范' },
{ key: 'design/icon', title: '图标库' },
],
},
{ key: 'frontend', title: '前端' },
{ key: 'backend', title: '后端' },
]
const selectedKeys = ref<string[]>(['design/ui'])
</script>
<template>
<div style="max-width: 320px">
<G3Tree v-model:selected-keys="selectedKeys" :tree-data="treeData" default-expand-all />
<p style="margin: 8px 0 0; font-size: 13px; color: #6b7280">选中:{{ selectedKeys.join(', ') || '无' }}</p>
</div>
</template>