First look at the code:

<el-form ref="form" :model="form" :rules="rules"  label-width="80px">
Copy the code

refAttribute involves getting a Dom element (an el-Form object).

JavaSrcipt gets the Dom element node by: document.querySelector (“.input”).

Vue introduces the REF attribute and $refs object to simplify DOM retrieval. The general operation flow is :ref binds the control, $refs retrieves the control.

Form validation:

this.$refs[formName].validate((valid) = > {
        if (valid) {}
        else{}

Copy the code