mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
e7aa014c31
* docs: init * chore: all types * docs: faq * chore: fix lint
49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import { Tree } from 'antd';
|
|
import type { GetProps, TreeDataNode } from 'antd';
|
|
|
|
type DirectoryTreeProps = GetProps<typeof Tree.DirectoryTree>;
|
|
|
|
const { DirectoryTree } = Tree;
|
|
|
|
const treeData: TreeDataNode[] = [
|
|
{
|
|
title: 'parent 0',
|
|
key: '0-0',
|
|
children: [
|
|
{ title: 'leaf 0-0', key: '0-0-0', isLeaf: true },
|
|
{ title: 'leaf 0-1', key: '0-0-1', isLeaf: true },
|
|
],
|
|
},
|
|
{
|
|
title: 'parent 1',
|
|
key: '0-1',
|
|
children: [
|
|
{ title: 'leaf 1-0', key: '0-1-0', isLeaf: true },
|
|
{ title: 'leaf 1-1', key: '0-1-1', isLeaf: true },
|
|
],
|
|
},
|
|
];
|
|
|
|
const App: React.FC = () => {
|
|
const onSelect: DirectoryTreeProps['onSelect'] = (keys, info) => {
|
|
console.log('Trigger Select', keys, info);
|
|
};
|
|
|
|
const onExpand: DirectoryTreeProps['onExpand'] = (keys, info) => {
|
|
console.log('Trigger Expand', keys, info);
|
|
};
|
|
|
|
return (
|
|
<DirectoryTree
|
|
multiple
|
|
defaultExpandAll
|
|
onSelect={onSelect}
|
|
onExpand={onExpand}
|
|
treeData={treeData}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default App;
|