/*! For license information please see 6865.db988c82.js.LICENSE.txt */ (self.webpackChunk=self.webpackChunk||[]).push([["6865"],{78365:function(s,n,a){"use strict";a.r(n);var t=a("80681");let e=["innerHTML"];n.default={setup:()=>({html:""}),render:()=>((0,t.wg)(),(0,t.iD)("div",{class:"van-doc-markdown-body",innerHTML:'
The rate component is used for rating things.
\nRegister component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';\nimport { Rate } from 'vant';\n\nconst app = createApp();\napp.use(Rate);\n
\n<van-rate v-model="value" />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const value = ref(3);\n return { value };\n },\n};\n
\n<van-rate v-model="value" icon="like" void-icon="like-o" />\n
\n<van-rate\n v-model="value"\n :size="25"\n color="#ffd21e"\n void-icon="star"\n void-color="#eee"\n/>\n
\n<van-rate v-model="value" allow-half />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const value = ref(2.5);\n return { value };\n },\n};\n
\n<van-rate v-model="value" :count="6" />\n
\nWhen the clearable
prop is set to true
, clicking on the same value again will reset the value to 0
.
<van-rate v-model="value" clearable />\n
\n<van-rate v-model="value" disabled />\n
\n<van-rate v-model="value" readonly />\n
\n<van-rate v-model="value" readonly />\n
\nimport { ref } from 'vue';\n\nexport default {\n setup() {\n const value = ref(3.3);\n return { value };\n },\n};\n
\n<van-rate v-model="value" @change="onChange" />\n
\nimport { ref } from 'vue';\nimport { showToast } from 'vant';\n\nexport default {\n setup() {\n const value = ref(3);\n const onChange = (value) => showToast('current value:' + value);\n return {\n value,\n onChange,\n };\n },\n};\n
\nAttribute | \nDescription | \nType | \nDefault | \n
---|---|---|---|
v-model | \nCurrent rate | \nnumber | \n- | \n
count | \nCount | \nnumber | string | \n5 | \n
size | \nIcon size | \nnumber | string | \n20px | \n
gutter | \nIcon gutter | \nnumber | string | \n4px | \n
color | \nSelected color | \nstring | \n#ee0a24 | \n
void-color | \nVoid color | \nstring | \n#c8c9cc | \n
disabled-color | \nDisabled color | \nstring | \n#c8c9cc | \n
icon | \nSelected icon | \nstring | \nstar | \n
void-icon | \nVoid icon | \nstring | \nstar-o | \n
icon-prefix | \nIcon className prefix | \nstring | \nvan-icon | \n
allow-half | \nWhether to allow half star | \nboolean | \nfalse | \n
clearable v4.6.0 | \nWhether to allow clear when click again | \nboolean | \nfalse | \n
readonly | \nWhether to be readonly | \nboolean | \nfalse | \n
disabled | \nWhether to disable rate | \nboolean | \nfalse | \n
touchable | \nWhether to allow select rate by touch gesture | \nboolean | \ntrue | \n
Event | \nDescription | \nParameters | \n
---|---|---|
change | \nEmitted when rate changed | \ncurrentValue: number | \n
The component exports the following type definitions:
\nimport type { RateProps } from 'vant';\n
\nThe component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
\nName | \nDefault Value | \nDescription | \n
---|---|---|
--van-rate-icon-size | \n20px | \n- | \n
--van-rate-icon-gutter | \nvar(--van-padding-base) | \n- | \n
--van-rate-icon-void-color | \nvar(--van-gray-5) | \n- | \n
--van-rate-icon-full-color | \nvar(--van-danger-color) | \n- | \n
--van-rate-icon-disabled-color | \nvar(--van-gray-5) | \n- | \n