mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-03 16:39:41 +08:00
55 lines
1.2 KiB
Markdown
55 lines
1.2 KiB
Markdown
|
---
|
||
|
order: 8
|
||
|
title:
|
||
|
zh-CN: 自定义展开/折叠图标
|
||
|
en-US: Customize collapse/expand icon
|
||
|
---
|
||
|
|
||
|
## zh-CN
|
||
|
|
||
|
自定义展开/折叠图标。
|
||
|
|
||
|
## en-US
|
||
|
|
||
|
customize collapse/expand icon of tree node
|
||
|
|
||
|
```jsx
|
||
|
import { Tree, Icon } from 'antd';
|
||
|
|
||
|
const { TreeNode } = Tree;
|
||
|
|
||
|
class Demo extends React.Component {
|
||
|
onSelect = (selectedKeys, info) => {
|
||
|
console.log('selected', selectedKeys, info);
|
||
|
};
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<Tree
|
||
|
showLine
|
||
|
switcherIcon={<Icon type="down" />}
|
||
|
defaultExpandedKeys={['0-0-0']}
|
||
|
onSelect={this.onSelect}
|
||
|
>
|
||
|
<TreeNode title="parent 1" key="0-0">
|
||
|
<TreeNode title="parent 1-0" key="0-0-0">
|
||
|
<TreeNode title="leaf" key="0-0-0-0" />
|
||
|
<TreeNode title="leaf" key="0-0-0-1" />
|
||
|
<TreeNode title="leaf" key="0-0-0-2" />
|
||
|
</TreeNode>
|
||
|
<TreeNode title="parent 1-1" key="0-0-1">
|
||
|
<TreeNode title="leaf" key="0-0-1-0" />
|
||
|
</TreeNode>
|
||
|
<TreeNode title="parent 1-2" key="0-0-2">
|
||
|
<TreeNode title="leaf" key="0-0-2-0" />
|
||
|
<TreeNode title="leaf" key="0-0-2-1" />
|
||
|
</TreeNode>
|
||
|
</TreeNode>
|
||
|
</Tree>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ReactDOM.render(<Demo />, mountNode);
|
||
|
```
|