You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
---
|
|
|
|
order: 6
|
|
|
|
title:
|
|
|
|
zh-CN: 自定义图标
|
|
|
|
en-US: Customize Icon
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
可以针对不同的节点定制图标。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
You can customize icons for different nodes.
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Tree, Icon } from 'antd';
|
|
|
|
|
|
|
|
const TreeNode = Tree.TreeNode;
|
|
|
|
|
|
|
|
class Demo extends React.Component {
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Tree
|
|
|
|
showIcon
|
|
|
|
defaultExpandAll
|
|
|
|
defaultSelectedKeys={['0-0-0']}
|
|
|
|
>
|
|
|
|
<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
|
|
|
|
icon={({ selected }) => (
|
|
|
|
<Icon type={selected ? 'frown' : 'frown-o'} />
|
|
|
|
)}
|
|
|
|
title="leaf"
|
|
|
|
key="0-0-1"
|
|
|
|
/>
|
|
|
|
</TreeNode>
|
|
|
|
</Tree>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
````
|