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.
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Tree } from 'antd';
|
2018-06-27 16:14:47 +08:00
|
|
|
|
2018-06-04 11:20:17 +08:00
|
|
|
const DirectoryTree = Tree.DirectoryTree;
|
2018-11-28 15:00:03 +08:00
|
|
|
const { TreeNode } = Tree;
|
2018-06-04 11:20:17 +08:00
|
|
|
|
|
|
|
class Demo extends React.Component {
|
2019-04-09 14:20:59 +08:00
|
|
|
onSelect = (keys, event) => {
|
|
|
|
console.log('Trigger Select', keys, event);
|
2018-06-04 11:20:17 +08:00
|
|
|
};
|
2018-06-27 16:14:47 +08:00
|
|
|
|
2018-06-04 11:20:17 +08:00
|
|
|
onExpand = () => {
|
|
|
|
console.log('Trigger Expand');
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<DirectoryTree
|
|
|
|
multiple
|
|
|
|
defaultExpandAll
|
|
|
|
onSelect={this.onSelect}
|
|
|
|
onExpand={this.onExpand}
|
|
|
|
>
|
|
|
|
<TreeNode title="parent 0" key="0-0">
|
|
|
|
<TreeNode title="leaf 0-0" key="0-0-0" isLeaf />
|
|
|
|
<TreeNode title="leaf 0-1" key="0-0-1" isLeaf />
|
|
|
|
</TreeNode>
|
|
|
|
<TreeNode title="parent 1" key="0-1">
|
|
|
|
<TreeNode title="leaf 1-0" key="0-1-0" isLeaf />
|
|
|
|
<TreeNode title="leaf 1-1" key="0-1-1" isLeaf />
|
|
|
|
</TreeNode>
|
|
|
|
</DirectoryTree>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
````
|