diff --git a/examples/routers/rate.vue b/examples/routers/rate.vue
index 7e9fba4f..d766a9bd 100644
--- a/examples/routers/rate.vue
+++ b/examples/routers/rate.vue
@@ -4,6 +4,11 @@
+
@@ -22,6 +27,7 @@
valueDisabled: 2.4,
valueClear: 1,
valueClearHalf: 1.5,
+ characterValue: 2.5
}
}
}
diff --git a/src/components/rate/rate.vue b/src/components/rate/rate.vue
index ad7082ae..376ac01e 100644
--- a/src/components/rate/rate.vue
+++ b/src/components/rate/rate.vue
@@ -5,8 +5,15 @@
v-for="item in count"
:class="starCls(item)"
@mousemove="handleMousemove(item, $event)"
+ :key="item"
@click="handleClick(item)">
-
+
+
+
+
+ {{character}}
+ {{character}}
+
{{ currentValue }} {{ t('i.rate.star') }}{{ t('i.rate.stars') }}
@@ -49,6 +56,10 @@
clearable: {
type: Boolean,
default: false
+ },
+ character: {
+ type: String,
+ default: ''
}
},
data () {
@@ -95,8 +106,9 @@
}
return [
- `${prefixCls}-star`,
- {
+ {
+ [`${prefixCls}-star`]: !this.character,
+ [`${prefixCls}-star-chart`]: this.character,
[`${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 d1ad1728..121799aa 100644
--- a/src/styles/components/rate.less
+++ b/src/styles/components/rate.less
@@ -19,6 +19,50 @@
}
}
+ &-star-full, &-star-zero {
+ position: relative;
+ }
+ &-star-first {
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 50%;
+ height: 100%;
+ overflow: hidden;
+ opacity: 0;
+ }
+
+ &-star-first, &-star-second {
+ user-select: none;
+ transition: all .3s ease;
+ color: #e9e9e9;
+ }
+
+ &-star-chart {
+ display: inline-block;
+ margin: 0;
+ padding: 0;
+ margin-right: 8px;
+ position: relative;
+ font-family: 'Ionicons';
+ transition: all 0.3s ease;
+
+ &:hover {
+ transform: scale(1.1);
+
+ &-star-first, &-star-second {
+ color: @rate-star-color;
+ }
+ }
+ }
+ &-star-chart&-star-full &-star-first, &-star-chart&-star-full &-star-second{
+ color: @rate-star-color;
+ }
+ &-star-chart&-star-half &-star-first{
+ opacity: 1;
+ color: @rate-star-color;
+ }
+
&-star {
display: inline-block;
margin: 0;