2017-03-21 09:41:02 +08:00
|
|
|
---
|
|
|
|
order: 6
|
|
|
|
title:
|
|
|
|
zh-CN: 自定义图标
|
|
|
|
en-US: Customize Icon
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2018-04-04 16:39:50 +08:00
|
|
|
可以针对不同的节点定制图标。
|
2017-03-21 09:41:02 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2018-04-04 16:39:50 +08:00
|
|
|
You can customize icons for different nodes.
|
2017-03-21 09:41:02 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2018-04-04 16:39:50 +08:00
|
|
|
import { Tree, Icon } from 'antd';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2018-11-28 15:00:03 +08:00
|
|
|
const { TreeNode } = Tree;
|
|
|
|
|
|
|
|
ReactDOM.render(
|
|
|
|
<Tree
|
|
|
|
showIcon
|
|
|
|
defaultExpandAll
|
|
|
|
defaultSelectedKeys={['0-0-0']}
|
2018-12-12 20:25:55 +08:00
|
|
|
switcherIcon={<Icon type="down" />}
|
2018-11-28 15:00:03 +08:00
|
|
|
>
|
|
|
|
<TreeNode icon={<Icon type="smile-o" />} title="parent 1" key="0-0">
|
|
|
|
<TreeNode icon={<Icon type="meh-o" />} title="leaf" key="0-0-0" />
|
|
|
|
<TreeNode
|
2019-05-07 14:57:32 +08:00
|
|
|
icon={({ selected }) => <Icon type={selected ? 'frown' : 'frown-o'} />}
|
2018-11-28 15:00:03 +08:00
|
|
|
title="leaf"
|
|
|
|
key="0-0-1"
|
|
|
|
/>
|
|
|
|
</TreeNode>
|
|
|
|
</Tree>,
|
2019-05-07 14:57:32 +08:00
|
|
|
mountNode,
|
2018-11-28 15:00:03 +08:00
|
|
|
);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|