TypeError: Cannot read properties of undefined (reading 'validate') ——vue-Element

浮夸小生。
2023-11-05 / 0 评论 / 211 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2023年11月05日,已超过178天没有更新,若内容或图片失效,请留言反馈。

问题

每一次都会犯相同的错误

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">
0

评论 (0)

取消