2018-06-04 11:20:17 +08:00
|
|
|
---
|
|
|
|
order: 7
|
|
|
|
title:
|
|
|
|
zh-CN: 目录
|
|
|
|
en-US: directory
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
内置的目录树,`multiple` 模式支持 `ctrl(Windows)` / `command(Mac)` 复选。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Built-in directory tree. `multiple` support `ctrl(Windows)` / `command(Mac)` selection.
|
|
|
|
|
2019-08-12 13:22:36 +08:00
|
|
|
```tsx
|
2018-06-04 11:20:17 +08:00
|
|
|
import { Tree } from 'antd';
|
2018-06-27 16:14:47 +08:00
|
|
|
|
2019-08-12 13:22:36 +08:00
|
|
|
const { DirectoryTree } = Tree;
|
|
|
|
|
|
|
|
const treeData = [
|
|
|
|
{
|
|
|
|
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 Demo: React.FC<{}> = () => {
|
2020-12-17 15:09:18 +08:00
|
|
|
const onSelect = (keys: React.Key[], info: any) => {
|
|
|
|
console.log('Trigger Select', keys, info);
|
2018-06-04 11:20:17 +08:00
|
|
|
};
|
2018-06-27 16:14:47 +08:00
|
|
|
|
2019-08-12 13:22:36 +08:00
|
|
|
const onExpand = () => {
|
2018-06-04 11:20:17 +08:00
|
|
|
console.log('Trigger Expand');
|
|
|
|
};
|
|
|
|
|
2019-08-12 13:22:36 +08:00
|
|
|
return (
|
|
|
|
<DirectoryTree
|
|
|
|
multiple
|
|
|
|
defaultExpandAll
|
|
|
|
onSelect={onSelect}
|
|
|
|
onExpand={onExpand}
|
|
|
|
treeData={treeData}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2018-06-04 11:20:17 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default Demo;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|