rate组件添加allowClear属性,通过点击可以把当前评分清零

This commit is contained in:
xiaofengsha 2018-04-26 01:00:39 +08:00
parent c45f05dd43
commit 1137640c3d

View file

@ -45,6 +45,10 @@
},
name: {
type: String
},
allowClear: {
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.allowClear && Math.abs(value - this.currentValue) < 0.01) {
value = 0;
}
this.currentValue = value;
this.$emit('input', value);
this.$emit('on-change', value);