Rate评分

评分组件。

何时使用#

  • 对评价进行展示。
  • 对事物进行快速的评级操作。
import { NzRateModule } from 'ng-zorro-antd/rate';

代码演示

最简单的用法。

expand codeexpand code
加载中
normal

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

expand codeexpand code
加载中
allowClear: true
allowClear: false

支持允许或者禁用清除。

expand codeexpand code
加载中
  • 1
    1
  • 2
    2
  • 3
    3
  • 4
    4
  • 5
    5


可以通过索引自定义每一个字符。

expand codeexpand code
加载中

支持选中半星。

expand codeexpand code
加载中

只读,无法进行鼠标交互。

expand codeexpand code
加载中

  • A
    A
  • A
    A
  • A
    A
  • A
    A
  • A
    A

可以将星星替换为其他字符,比如字母,数字,字体图标甚至中文。

expand codeexpand code
加载中

API#

nz-rate#

属性说明类型默认值支持全局配置
[nzAllowClear]是否允许再次点击后清除booleantrue
[nzAllowHalf]是否允许半选booleanfalse
[nzAutoFocus]自动获取焦点booleanfalse
[nzCharacter]自定义字符TemplateRef<void><span nz-icon nzType="star"></span>
[nzCount]star 总数number5
[nzDisabled]只读,无法进行交互booleanfalse
[nzTooltips]自定义每项的提示信息string[][]
[ngModel]当前数,可以双向绑定number0
(ngModelChange)当前数改变时的回调EventEmitter<number>-
(nzOnBlur)失去焦点时的回调EventEmitter<FocusEvent>-
(nzOnFocus)获取焦点时的回调EventEmitter<FocusEvent>-
(nzOnHoverChange)鼠标经过时数值变化的回调EventEmitter<number>-
(nzOnKeyDown)按键回调EventEmitter<KeyboardEvent>-

方法#

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