Rating

Updated at:

Introduction

The Rating component is a basic Moflow component used for rating.

image

Configuration items

Category

Configuration item

Example

Description

Content

Default value

The default rating value. This is an integer. The default step value is 1.

Total

The number of icons.

Label

The label. For more information, see Common form properties.

Label configuration

The label configuration. For more information, see Common form properties.

Interaction

Hidden

Hides the component. For more information, see Common properties.

Allow clear on re-click

Click the selection again to clear it.

Allow partial selection

Lets you select a half rating. If you enable this option, the step value is 0.5.

Disabled

Disables interaction with the component.

Validation

Required

Validation. For more information, see Common form properties.

Style

Margin

The margin. For more information, see Common properties.

Icon type

Lets you select different icon types.

Note:

image

Customize the tooltip for each item.

Properties and methods

Name

Type

Example

Description

value

number

rate.value

The score of the Rating component.

count

number

rate.count

The total number of icons in the Rating component.

allowClear

boolean

rate.allowClear

Read-only. Specifies whether the value of the Rating component can be cleared by clicking the rating again.

allowHalf

boolean

rate.allowHalf

Read-only. Specifies whether half-ratings are allowed.

disabled

boolean

rate.disabled

Specifies whether to disable the Rating component.

hidden

boolean

rate.hidden

Specifies whether the component is hidden.

clearCount

func

rate.clearCount()

Clears the value of the `count` property.

clearDisabled

func

rate.clearDisabled()

Clears the value of the `disabled` property.

clearHidden

func

rate.clearHidden()

Clears the value of the `hidden` property.

clearValidate

func

rate.clearValidate()

Clears the validation status of the component.

clearValue

func

rate.clearValue()

Clears the value of the `value` property.

setValue

func

rate.setValue(3)

Sets the rating score.

setCount

func

rate.setCount(5)

Sets the total number of icons.

setDisabled

func

rate.setDisabled(true)

Sets whether the component is disabled.

setHidden

func

rate.setHidden(true)

Sets whether the component is hidden.

validate

func

rate.validate()

Validates the component.

validationStatus

boolean

rate.validationStatus

The validation status of the component.

validationMessage

string

rate.validationMessage

The validation message of the component.

Event callbacks

Configuration item

Description

Callback for when the rating value changes.

Callback for when the component gains focus.

Callback for when the value changes on mouse hover.

Callback for when the component loses focus.

Scenario example

E-commerce order reviews

  • This is a typical scenario for the Rating component. You can set different review items as needed.

image