mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
fix(Stepper): can't work when step is small (#4675)
This commit is contained in:
parent
cc03640576
commit
e4bdd50d4b
@ -11,6 +11,12 @@ function equal(value1, value2) {
|
|||||||
return String(value1) === String(value2);
|
return String(value1) === String(value2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add num and avoid float number
|
||||||
|
function add(num1, num2) {
|
||||||
|
const cardinal = 10 ** 10;
|
||||||
|
return Math.round((num1 + num2) * cardinal) / cardinal;
|
||||||
|
}
|
||||||
|
|
||||||
export default createComponent({
|
export default createComponent({
|
||||||
props: {
|
props: {
|
||||||
value: null,
|
value: null,
|
||||||
@ -171,14 +177,7 @@ export default createComponent({
|
|||||||
|
|
||||||
const diff = type === 'minus' ? -this.step : +this.step;
|
const diff = type === 'minus' ? -this.step : +this.step;
|
||||||
|
|
||||||
let value = +this.currentValue + diff;
|
const value = this.format(add(+this.currentValue, diff));
|
||||||
|
|
||||||
// avoid float number
|
|
||||||
if (!isDef(this.decimalLength)) {
|
|
||||||
value = Math.round(value * 100) / 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
value = this.format(value);
|
|
||||||
|
|
||||||
this.emitChange(value);
|
this.emitChange(value);
|
||||||
this.$emit(type);
|
this.$emit(type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user