浏览代码

When <el-form> missing `model`, validate will return false, then throw a warning to facilitate the developer troubleshooting

leezng 8 年之前
父节点
当前提交
ce270fef4d
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      packages/form/src/form.vue

+ 4 - 0
packages/form/src/form.vue

@@ -62,6 +62,10 @@
         });
       },
       validate(callback) {
+        if (!this.model) {
+          console.warn('[Element Warn][Form]model is required for validate to work!');
+          return;
+        };
         let valid = true;
         let count = 0;
         // 如果需要验证的fields为空,调用验证时立刻返回callback