问题

每一次都会犯相同的错误

this.$refs[formName].validate((valid) => {
  if (valid) {
    alert('submit!');
  } else {
    console.log('error submit!!');
    return false;
  }
});

表单校验 报错 TypeError: Cannot read properties of undefined (reading 'validate') ——vue-Element.....

只需要在 form标签上添加 :ref ="" ------完美解决

<el-form :ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" autocomplete="on" label-position="left">
最后修改:2023 年 11 月 05 日
如果觉得我的文章对你有用,请随意赞赏