rate组件添加allowClear属性,通过点击可以把当前评分清零
This commit is contained in:
parent
c45f05dd43
commit
1137640c3d
1 changed files with 10 additions and 1 deletions
|
@ -45,6 +45,10 @@
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: String
|
type: String
|
||||||
|
},
|
||||||
|
allowClear: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
|
@ -123,8 +127,13 @@
|
||||||
},
|
},
|
||||||
handleClick (value) {
|
handleClick (value) {
|
||||||
if (this.disabled) return;
|
if (this.disabled) return;
|
||||||
// value++;
|
//value++;
|
||||||
if (this.isHalf) value -= 0.5;
|
if (this.isHalf) value -= 0.5;
|
||||||
|
|
||||||
|
if(this.allowClear && Math.abs(value - this.currentValue) < 0.01) {
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.currentValue = value;
|
this.currentValue = value;
|
||||||
this.$emit('input', value);
|
this.$emit('input', value);
|
||||||
this.$emit('on-change', value);
|
this.$emit('on-change', value);
|
||||||
|
|
Loading…
Add table
Reference in a new issue