Skip to content

Rate 评分

用于评分

基础用法

自定义图标

自定义样式

允许半选

辅助文字

可清空

只读

API

Props

参数说明类型默认值
model-value / v-model选中项绑定值number0
max最大分值number5
sizeSVG 图标的大小,如 20px 2em,默认单位为 pxnumber / string18px
gutter图标间距,默认单位为pxnumber / string4px
disabled是否为只读booleanfalse
allow-half是否允许半选booleanfalse
low-threshold低分和中等分数的界限值, 值本身被划分在低分中number2
high-threshold高分和中等分数的界限值, 值本身被划分在高分中number4
colorsicon 的颜色。 若传入数组,共有 3 个元素,为 3 个分段所对应的颜色;若传入对象,可自定义分段,键名为分段的界限值,键值为对应的颜色object['#f7ba2a', '#f7ba2a', '#f7ba2a']
void-color未选中 icon 的颜色string#c6d1de
disabled-void-color只读时未选中 icon 的颜色string#eff2f7
icons图标组件 若传入数组,则需要传入 3 个元素,分别为 3 个部分所对应的类名;若传入对象,则可自定义分段,键名为分段的界限值,键值为对应的类名object[StarFilled, StarFilled, StarFilled]
void-icon未被选中的图标组件string / ComponentStar
disabled-void-icon禁用状态的未选择图标string / ComponentStarFilled
show-text是否显示辅助文字,若为真,则会从 texts 数组中选取当前分数对应的文字内容booleanfalse
show-score是否显示当前分数, show-score 和 show-text 不能同时为真booleanfalse
text-color辅助文字的颜色string''
texts辅助文字数组array['Extremely bad', 'Disappointed', 'Fair', 'Satisfied', 'Surprise']
score-template分数显示模板string
clearable是否可以重置值为 0booleanfalse
id原生 id 属性string

Events

事件名说明回调参数
change分值改变时触发Function

方法

通过 ref 可以获取到 CountDown 实例并调用实例方法,详见组件实例方法

方法名说明方法类型
setCurrentValue设置当前值Function
resetCurrentValue重置当前值Function

类型定义

组件导出以下类型定义:

ts
import type { RateProps } from 'ryxon'

主题定制

样式变量

组件提供了下列 CSS 变量,可用于自定义样式,使用方法请参考 ConfigProvider 组件

名称默认值描述
--r-rate-font-sizevar(--r-font-size-md)-
--r-rate-void-colorvar(--r-gray-5)-
--r-rate-fill-color#f7ba2a-
--r-rate-disabled-void-colorvar(--r-fill-color)-
--r-rate-text-colorvar(--r-text-color-primary)-

Released under the MIT License.