mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +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);
|
||||
}
|
||||
|
||||
// add num and avoid float number
|
||||
function add(num1, num2) {
|
||||
const cardinal = 10 ** 10;
|
||||
return Math.round((num1 + num2) * cardinal) / cardinal;
|
||||
}
|
||||
|
||||
export default createComponent({
|
||||
props: {
|
||||
value: null,
|
||||
@ -171,14 +177,7 @@ export default createComponent({
|
||||
|
||||
const diff = type === 'minus' ? -this.step : +this.step;
|
||||
|
||||
let value = +this.currentValue + diff;
|
||||
|
||||
// avoid float number
|
||||
if (!isDef(this.decimalLength)) {
|
||||
value = Math.round(value * 100) / 100;
|
||||
}
|
||||
|
||||
value = this.format(value);
|
||||
const value = this.format(add(+this.currentValue, diff));
|
||||
|
||||
this.emitChange(value);
|
||||
this.$emit(type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user