mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +08:00
64b905e9bd
* update icons deps * update all icon ref * fix lint * update snapshot
57 lines
879 B
Markdown
57 lines
879 B
Markdown
---
|
|
order: 6
|
|
title:
|
|
zh-CN: 自定义图标
|
|
en-US: Customize Icon
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
可以针对不同的节点定制图标。
|
|
|
|
## en-US
|
|
|
|
You can customize icons for different nodes.
|
|
|
|
```jsx
|
|
import { Tree } from 'antd';
|
|
import {
|
|
DownOutlined,
|
|
FrownOutlined,
|
|
SmileOutlined,
|
|
MehOutlined,
|
|
FrownFilled,
|
|
} from '@ant-design/icons';
|
|
|
|
const treeData = [
|
|
{
|
|
title: 'parent 1',
|
|
key: '0-0',
|
|
icon: <SmileOutlined />,
|
|
children: [
|
|
{
|
|
title: 'leaf',
|
|
key: '0-0-0',
|
|
icon: <MehOutlined />,
|
|
},
|
|
{
|
|
title: 'leaf',
|
|
key: '0-0-1',
|
|
icon: ({ selected }) => (selected ? <FrownFilled /> : <FrownOutlined />),
|
|
},
|
|
],
|
|
},
|
|
];
|
|
|
|
ReactDOM.render(
|
|
<Tree
|
|
showIcon
|
|
defaultExpandAll
|
|
defaultSelectedKeys={['0-0-0']}
|
|
switcherIcon={<DownOutlined />}
|
|
treeData={treeData}
|
|
/>,
|
|
mountNode,
|
|
);
|
|
```
|