diff --git a/examples/routers/rate.vue b/examples/routers/rate.vue
index d766a9bd..29479113 100644
--- a/examples/routers/rate.vue
+++ b/examples/routers/rate.vue
@@ -9,6 +9,7 @@
show-text
v-model="characterValue"
character="好"/>
+
@@ -27,7 +28,8 @@
valueDisabled: 2.4,
valueClear: 1,
valueClearHalf: 1.5,
- characterValue: 2.5
+ characterValue: 2.5,
+ cv: 3.5
}
}
}
diff --git a/src/components/rate/rate.vue b/src/components/rate/rate.vue
index 376ac01e..e6baf46d 100644
--- a/src/components/rate/rate.vue
+++ b/src/components/rate/rate.vue
@@ -7,13 +7,23 @@
@mousemove="handleMousemove(item, $event)"
:key="item"
@click="handleClick(item)">
-
+
-
-
- {{character}}
- {{character}}
-
+
+
+
+ {{ character }}
+ {{ character }}
+
+
+
+
+
+
+
+
+
+
{{ currentValue }} {{ t('i.rate.star') }}{{ t('i.rate.stars') }}
@@ -24,11 +34,14 @@
import Locale from '../../mixins/locale';
import Emitter from '../../mixins/emitter';
+ import Icon from '../icon/icon.vue';
+
const prefixCls = 'ivu-rate';
export default {
name: 'Rate',
mixins: [ Locale, Emitter ],
+ components: { Icon },
props: {
count: {
type: Number,
@@ -60,6 +73,14 @@
character: {
type: String,
default: ''
+ },
+ icon: {
+ type: String,
+ default: ''
+ },
+ customIcon: {
+ type: String,
+ default: ''
}
},
data () {
@@ -79,6 +100,18 @@
[`${prefixCls}-disabled`]: this.disabled
}
];
+ },
+ iconClasses () {
+ return [
+ `ivu-icon`,
+ {
+ [`ivu-icon-${this.icon}`]: this.icon !== '',
+ [`${this.customIcon}`]: this.customIcon !== '',
+ }
+ ];
+ },
+ showCharacter () {
+ return this.character !== '' || this.icon !== '' || this.customIcon !== '';
}
},
watch: {
@@ -107,8 +140,8 @@
return [
{
- [`${prefixCls}-star`]: !this.character,
- [`${prefixCls}-star-chart`]: this.character,
+ [`${prefixCls}-star`]: !this.showCharacter,
+ [`${prefixCls}-star-chart`]: this.showCharacter,
[`${prefixCls}-star-full`]: (!isLast && full) || (isLast && !this.isHalf),
[`${prefixCls}-star-half`]: isLast && this.isHalf,
[`${prefixCls}-star-zero`]: !full
diff --git a/src/styles/components/rate.less b/src/styles/components/rate.less
index 121799aa..c5c818cb 100644
--- a/src/styles/components/rate.less
+++ b/src/styles/components/rate.less
@@ -36,6 +36,7 @@
user-select: none;
transition: all .3s ease;
color: #e9e9e9;
+ cursor: pointer;
}
&-star-chart {