mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-24 02:20:01 +08:00
6776bb8916
* docs: update demo * chore: add script * test: fix demo test * docs: convert demos * chore: move script * test: remove react-dom import * chore: update deps * docs: update riddle js * test: fix image test * docs: fix riddle demo
36 lines
700 B
Markdown
36 lines
700 B
Markdown
---
|
|
order: 6
|
|
title:
|
|
zh-CN: 自定义字符
|
|
en-US: Customize character
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
可以使用 `(RateProps) => ReactNode` 的方式自定义每一个字符。
|
|
|
|
## en-US
|
|
|
|
Can customize each character using `(RateProps) => ReactNode`.
|
|
|
|
```jsx
|
|
import { Rate } from 'antd';
|
|
import { FrownOutlined, MehOutlined, SmileOutlined } from '@ant-design/icons';
|
|
|
|
const customIcons = {
|
|
1: <FrownOutlined />,
|
|
2: <FrownOutlined />,
|
|
3: <MehOutlined />,
|
|
4: <SmileOutlined />,
|
|
5: <SmileOutlined />,
|
|
};
|
|
|
|
export default () => (
|
|
<>
|
|
<Rate defaultValue={2} character={({ index }) => index + 1} />
|
|
<br />
|
|
<Rate defaultValue={3} character={({ index }) => customIcons[index + 1]} />
|
|
</>
|
|
);
|
|
```
|