Rate 별점
Rate는 빠른 별점 평가나 리뷰 표시에 쓰는 컴포넌트예요. 반 개, 아이콘·개수·색상 커스텀까지 지원하죠.
출처: 문서
본문
설치
@nutui/nutui에서 컴포넌트를 가져와 앱에 등록하면 바로 쓸 수 있어요.
import { createApp } from 'vue'
import { Rate } from '@nutui/nutui'
const app = createApp()
app.use(Rate)
사용 예시
기본 사용법
demo: rate basic
반 개
demo: rate half
아이콘 커스터마이즈
demo: rate icon
개수 커스터마이즈
demo: rate count
색상 커스터마이즈
demo: rate color
비활성화
demo: rate disabled
읽기 전용
demo: rate read
이벤트 바인딩
demo: rate event
크기 커스터마이즈 35px
demo: rate size
API
Props
| Attribute | Description | Type | Default |
|---|---|---|---|
| v-model | The current number of stars, you can use v-model to bind data in both directions | number | string | - |
| count | Total number | string of stars | number | string | 5 |
| active-color | Icon selection color | string | #fa200c |
| void-color | Icon unselected color | string | #ccc |
| allow-half | half star | boolean | false |
| readonly | read-only | boolean | false |
| disabled | whether to disable | boolean | false |
| spacing | spacing | number | string | 20 |
| touchable | Whether to allow select rate by touch gesture | boolean | true |
| size | Icon custom size , eg 20px 2em 2rem |
number | string | - |
| custom-icon | custom Icon, set VNode |
VNode | h | StarFillN |
Events
| Event | Description | Arguments |
|---|---|---|
| change | An event that fires whenever the current score is modified | val |
Types v4.3.3
이 컴포넌트는 아래 타입 정의를 함께 내보내요.
import type {
RateProps,
RateInstance
} from '@nutui/nutui';
Theming
CSS Variables
스타일 커스텀에 쓸 수 있는 CSS 변수를 제공해요. 자세한 내용은 ConfigProvider 컴포넌트를 참고하세요.
| Name | Default Value |
|---|---|
| --nut-rate-icon-color | var(--nut-primary-color) |
| --nut-rate-icon-void-color | var(--nut-disable-color) |
더 알아보기 (Learn more)
- 원문 문서: NutUI Rate 공식 문서(영문)
- NutUI는 JD.com이 공개한 Vue 3 모바일 컴포넌트 라이브러리예요. 전체 컴포넌트 목록은 공식 문서 사이트에서, 소스 코드는 GitHub 저장소에서 볼 수 있어요.