Merge pull request #3853 from wqzwh/2.0
feature: rate组件增加character自定义字符配置项
This commit is contained in:
commit
1ead5bb6c4
3 changed files with 65 additions and 3 deletions
|
@ -4,6 +4,11 @@
|
||||||
<Rate allow-half v-model="valueHalf"></Rate>
|
<Rate allow-half v-model="valueHalf"></Rate>
|
||||||
<Rate clearable v-model="valueClear"></Rate>
|
<Rate clearable v-model="valueClear"></Rate>
|
||||||
<Rate clearable allow-half v-model="valueClearHalf"></Rate>
|
<Rate clearable allow-half v-model="valueClearHalf"></Rate>
|
||||||
|
<Rate
|
||||||
|
allow-half
|
||||||
|
show-text
|
||||||
|
v-model="characterValue"
|
||||||
|
character="好"/>
|
||||||
<!--<Rate show-text v-model="valueText"></Rate>-->
|
<!--<Rate show-text v-model="valueText"></Rate>-->
|
||||||
<!--<Rate show-text allow-half v-model="valueCustomText">-->
|
<!--<Rate show-text allow-half v-model="valueCustomText">-->
|
||||||
<!--<span style="color: #f5a623">{{ valueCustomText }}</span>-->
|
<!--<span style="color: #f5a623">{{ valueCustomText }}</span>-->
|
||||||
|
@ -22,6 +27,7 @@
|
||||||
valueDisabled: 2.4,
|
valueDisabled: 2.4,
|
||||||
valueClear: 1,
|
valueClear: 1,
|
||||||
valueClearHalf: 1.5,
|
valueClearHalf: 1.5,
|
||||||
|
characterValue: 2.5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,15 @@
|
||||||
v-for="item in count"
|
v-for="item in count"
|
||||||
:class="starCls(item)"
|
:class="starCls(item)"
|
||||||
@mousemove="handleMousemove(item, $event)"
|
@mousemove="handleMousemove(item, $event)"
|
||||||
|
:key="item"
|
||||||
@click="handleClick(item)">
|
@click="handleClick(item)">
|
||||||
<span :class="[prefixCls + '-star-content']" type="half"></span>
|
<div :class="starCls(item)" v-if="!character">
|
||||||
|
<span :class="[prefixCls + '-star-content']" type="half"></span>
|
||||||
|
</div>
|
||||||
|
<div :class="starCls(item)" v-else>
|
||||||
|
<span :class="[prefixCls + '-star-first']" type="half">{{character}}</span>
|
||||||
|
<span :class="[prefixCls + '-star-second']">{{character}}</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div :class="[prefixCls + '-text']" v-if="showText" v-show="currentValue > 0">
|
<div :class="[prefixCls + '-text']" v-if="showText" v-show="currentValue > 0">
|
||||||
<slot><span>{{ currentValue }}</span> <span v-if="currentValue <= 1">{{ t('i.rate.star') }}</span><span v-else>{{ t('i.rate.stars') }}</span></slot>
|
<slot><span>{{ currentValue }}</span> <span v-if="currentValue <= 1">{{ t('i.rate.star') }}</span><span v-else>{{ t('i.rate.stars') }}</span></slot>
|
||||||
|
@ -49,6 +56,10 @@
|
||||||
clearable: {
|
clearable: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
character: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -95,8 +106,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
`${prefixCls}-star`,
|
{
|
||||||
{
|
[`${prefixCls}-star`]: !this.character,
|
||||||
|
[`${prefixCls}-star-chart`]: this.character,
|
||||||
[`${prefixCls}-star-full`]: (!isLast && full) || (isLast && !this.isHalf),
|
[`${prefixCls}-star-full`]: (!isLast && full) || (isLast && !this.isHalf),
|
||||||
[`${prefixCls}-star-half`]: isLast && this.isHalf,
|
[`${prefixCls}-star-half`]: isLast && this.isHalf,
|
||||||
[`${prefixCls}-star-zero`]: !full
|
[`${prefixCls}-star-zero`]: !full
|
||||||
|
|
|
@ -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 {
|
&-star {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue