Rate: fix initial display of decimal value

pull/5390/merge
Leopoldthecoder 2017-07-10 19:21:40 +08:00 committed by 杨奕
parent 0137e5b80a
commit 77aebbdd33
1 changed files with 6 additions and 2 deletions

View File

@ -33,7 +33,7 @@
return { return {
classMap: {}, classMap: {},
colorMap: {}, colorMap: {},
pointerAtLeftHalf: false, pointerAtLeftHalf: true,
currentValue: this.value, currentValue: this.value,
hoverIndex: -1 hoverIndex: -1
}; };
@ -178,6 +178,7 @@
value(val) { value(val) {
this.$emit('change', val); this.$emit('change', val);
this.currentValue = val; this.currentValue = val;
this.pointerAtLeftHalf = this.value !== Math.floor(this.value);
} }
}, },
@ -197,7 +198,10 @@
showDecimalIcon(item) { showDecimalIcon(item) {
let showWhenDisabled = this.disabled && this.valueDecimal > 0 && item - 1 < this.value && item > this.value; let showWhenDisabled = this.disabled && this.valueDecimal > 0 && item - 1 < this.value && item > this.value;
/* istanbul ignore next */ /* istanbul ignore next */
let showWhenAllowHalf = this.allowHalf && this.pointerAtLeftHalf && ((item - 0.5).toFixed(1) === this.currentValue.toFixed(1)); let showWhenAllowHalf = this.allowHalf &&
this.pointerAtLeftHalf &&
item - 0.5 <= this.currentValue &&
item > this.currentValue;
return showWhenDisabled || showWhenAllowHalf; return showWhenDisabled || showWhenAllowHalf;
}, },