Selaa lähdekoodia

Slider: fix a NaN value bug (#1286)

杨奕 8 vuotta sitten
vanhempi
commit
2e3ecd93e7
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4 2
      packages/slider/src/main.vue

+ 4 - 2
packages/slider/src/main.vue

@@ -107,7 +107,7 @@
         this.$nextTick(() => {
           this.updatePopper();
         });
-        if (val < this.min) {
+        if (typeof val !== 'number' || isNaN(val) || val < this.min) {
           this.$emit('input', this.min);
           return;
         }
@@ -221,7 +221,9 @@
     },
 
     created() {
-      if (typeof this.value !== 'number' || this.value < this.min) {
+      if (typeof this.value !== 'number' ||
+        isNaN(this.value) ||
+        this.value < this.min) {
         this.$emit('input', this.min);
       } else if (this.value > this.max) {
         this.$emit('input', this.max);