---
title: Rate - 评分
path: /rate
nav:
  order: 1
  title: 桌面组件
  path: /design
group:
  order: 3
  title: 数据录入
  path: /dataInput
---

对评价进行展示。对事物进行快速的评级操作。

## 基础评分

通过鼠标悬浮选择来进行评分。

<code src="./demos/basic.tsx" height="400px"/>

## 半选评分

支持选中半星。

<code src="./demos/half.tsx" height="400px"/>

## 附有文案评分

给评分组件加上文案展示。

<code src="./demos/text.tsx" height="400px"/>

## 只可读评分

只读，无法进行鼠标交互，无法修改评分。

<code src="./demos/disabled.tsx" height="400px"/>

## 显示提示信息评分

为每一个评级提供鼠标悬浮时的提示信息。

<code src="./demos/tooltips.tsx" height="400px"/>

## 任意长度评分

可以通过设置参数来打造任意长度的评分组件。

<code src="./demos/count.tsx" height="400px"/>

## 自定义字符评分

可以通过替换字符来打造自己独特的评分

<code src="./demos/character.tsx" height="400px"/>

## API

| 属性          | 说明                     | 类型                                  | 默认值            | 版本              |
| ------------- | ------------------------ | ------------------------------------- | ----------------- | ----------------- |
| allowClear    | 是否允许再次点击后清除   | boolean                               | true              |                   |
| allowHalf     | 是否允许半选             | boolean                               | false             |                   |
| autoFocus     | 自动获取焦点             | boolean                               | false             |                   |
| character     | 自定义字符               | ReactNode \| (RateProps) => ReactNode | &lt;StarFilled /> | function(): 4.4.0 |
| className     | 自定义样式类名           | string                                | -                 |                   |
| count         | star 总数                | number                                | 5                 |                   |
| defaultValue  | 默认值                   | number                                | 0                 |                   |
| disabled      | 只读，无法进行交互       | boolean                               | false             |                   |
| style         | 自定义样式对象           | CSSProperties                         | -                 |                   |
| tooltips      | 自定义每项的提示信息     | string\[]                             | -                 |                   |
| value         | 当前数，受控值           | number                                | -                 |                   |
| onBlur        | 失去焦点时的回调         | function()                            | -                 |                   |
| onChange      | 选择时的回调             | function(value: number)               | -                 |                   |
| onFocus       | 获取焦点时的回调         | function()                            | -                 |                   |
| onHoverChange | 鼠标经过时数值变化的回调 | function(value: number)               | -                 |                   |
| onKeyDown     | 按键回调                 | function(event)                       | -                 |                   |

## 方法

| 名称    | 描述     |
| ------- | -------- |
| blur()  | 移除焦点 |
| focus() | 获取焦点 |
