import Vue from 'vue';
import { Rate } from 'vant';
Vue.use(Rate);
<van-rate v-model="value" />
export default {
data() {
return {
value: 3
};
}
}
<van-rate
v-model="value"
icon="like"
void-icon="like-o"
/>
<van-rate
v-model="value"
:size="25"
color="#ee0a24"
void-icon="star"
void-color="#eee"
/>
<van-rate
v-model="value"
allow-half
void-icon="star"
void-color="#eee"
/>
export default {
data() {
return {
value: 2.5
};
}
}
<van-rate v-model="value" :count="6" />
<van-rate v-model="value" disabled />
<van-rate v-model="value" readonly />
<van-rate v-model="value" @change="onChange" />
export default {
method: {
onChange(value) {
Toast('current value:'+ value);
}
}
}
Attribute |
Description |
Type |
Default |
v-model |
Current rate |
number |
- |
count |
Count |
number | string |
5 |
size |
Icon size |
number | string |
20px |
gutter |
Icon gutter |
number | string |
4px |
color |
Selected color |
string |
#ffd21e |
void-color |
Void color |
string |
#c8c9cc |
disabled-color |
Disabled color |
string |
#bdbdbd |
icon |
Selected icon |
string |
star |
void-icon |
Void icon |
string |
star-o |
icon-prefix v2.5.3 |
Icon className prefix |
string |
van-icon |
allow-half |
Whether to allow half star |
boolean |
false |
readonly |
Whether to be readonly |
boolean |
false |
disabled |
Whether to disable rate |
boolean |
false |
touchable v2.2.0 |
Whether to allow select rate by touch gesture |
boolean |
true |
Event |
Description |
Parameters |
change |
Triggered when rate changed |
current rate |