Merge pull request #3487 from xiaofengsha/pr007

rate组件添加allowClear属性,通过点击可以把当前评分清零
This commit is contained in:
Aresn 2018-05-03 11:54:59 +08:00 committed by GitHub
commit ca1b7bfaa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View file

@ -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);