浏览代码

Slider: warn against min being greater than max (#9997)

杨奕 7 年之前
父节点
当前提交
067a9be7d1
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      packages/slider/src/main.vue

+ 5 - 1
packages/slider/src/main.vue

@@ -193,6 +193,10 @@
         }
       },
       setValues() {
+        if (this.min > this.max) {
+          console.error('[Element Error][Slider]min should not be greater than max.');
+          return;
+        }
         const val = this.value;
         if (this.range && Array.isArray(val)) {
           if (val[1] < this.min) {
@@ -269,7 +273,7 @@
 
     computed: {
       stops() {
-        if (!this.showStops) return [];
+        if (!this.showStops || this.min > this.max) return [];
         if (this.step === 0) {
           process.env.NODE_ENV !== 'production' &&
           console.warn('[Element Warn][Slider]step should not be 0.');