Bladeren bron

InputNumber: fix invalid value (#1330)

kingwl 8 jaren geleden
bovenliggende
commit
6cd01c2647
1 gewijzigde bestanden met toevoegingen van 6 en 4 verwijderingen
  1. 6 4
      packages/input-number/src/input-number.vue

+ 6 - 4
packages/input-number/src/input-number.vue

@@ -175,15 +175,17 @@
         return (arg1 + arg2) / m;
       },
       increase() {
-        if (this.value + this.step > this.max || this.disabled) return;
-        this.currentValue = this.accAdd(this.step, this.value);
+        const value = this.value || 0;
+        if (value + this.step > this.max || this.disabled) return;
+        this.currentValue = this.accAdd(this.step, value);
         if (this.maxDisabled) {
           this.inputActive = false;
         }
       },
       decrease() {
-        if (this.value - this.step < this.min || this.disabled) return;
-        this.currentValue = this.accSub(this.value, this.step);
+        const value = this.value || 0;
+        if (value - this.step < this.min || this.disabled) return;
+        this.currentValue = this.accSub(value, this.step);
         if (this.minDisabled) {
           this.inputActive = false;
         }