ant-design/components/tree/demo/customized-icon.md

50 lines
798 B
Markdown
Raw Normal View History

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