Merge pull request #3487 from xiaofengsha/pr007
rate组件添加allowClear属性,通过点击可以把当前评分清零
This commit is contained in:
commit
ca1b7bfaa6
2 changed files with 15 additions and 2 deletions
|
@ -2,6 +2,8 @@
|
|||
<div>
|
||||
<Rate v-model="value"></Rate>
|
||||
<Rate allow-half v-model="valueHalf"></Rate>
|
||||
<Rate clearable v-model="valueClear"></Rate>
|
||||
<Rate clearable allow-half v-model="valueClearHalf"></Rate>
|
||||
<!--<Rate show-text v-model="valueText"></Rate>-->
|
||||
<!--<Rate show-text allow-half v-model="valueCustomText">-->
|
||||
<!--<span style="color: #f5a623">{{ valueCustomText }}</span>-->
|
||||
|
@ -17,7 +19,9 @@
|
|||
valueHalf: 2.5,
|
||||
valueText: 3,
|
||||
valueCustomText: 4.0,
|
||||
valueDisabled: 2.4
|
||||
valueDisabled: 2.4,
|
||||
valueClear: 1,
|
||||
valueClearHalf: 1.5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
},
|
||||
name: {
|
||||
type: String
|
||||
},
|
||||
clearable: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
|
@ -123,8 +127,13 @@
|
|||
},
|
||||
handleClick (value) {
|
||||
if (this.disabled) return;
|
||||
// value++;
|
||||
//value++;
|
||||
if (this.isHalf) value -= 0.5;
|
||||
|
||||
if(this.clearable && Math.abs(value - this.currentValue) < 0.01) {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
this.currentValue = value;
|
||||
this.$emit('input', value);
|
||||
this.$emit('on-change', value);
|
||||
|
|
Loading…
Add table
Reference in a new issue