preface

$this.$refs[formName].validate() indicates that validate() is not defined.

Question why

The DOM to validate has not been loaded yet.

The solution

$refs[formName] print this.$refs[formName] to check that you have the correct form to validate.

Secondly, after getting the correct form, check whether the form added on the form is correct. The following points need to be noted:

  1. Prop must be written before using this method<el-form-item>It’s on the label. It’s on the insideinputNot on or anywhere else (el-form-itemProp property binding)
  2. el-form rules.modelProperty binding,reflogo

The solutions to problem 1 are as follows:

this.$nextTick(()  =>{
 
})
Copy the code

For details on how to use $nextTick, please refer to the blog post “Vue Advanced (62) : Understanding $nextTick()”.