vue写后台登录出现Error in v-on handler: "TypeError: Cannot read property 'validate' of undefined"

原因1:

看一下表单验证的代码,找到这一句:

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

看看这里refs的值与el-form上绑定的ref值一直不一致,注意:refs和ref名字需要保持一致

 

 

 原因2:

@click="submitForm(ruleForm)" 中的 ruleForm 没有使用引号。

正确写法:

 <el-button type="primary" @click="submitForm('loginForm')">SIFN IN</el-button>
posted @ 2021-05-12 20:51  安琪吖  阅读(3638)  评论(0编辑  收藏  举报