1、我也不知道原因是什么,找了半天不知道为什么会触发,所以我在点击切换的时候做了清空表单校验
2、直接上代码
loginOrRegister(val) {
// 方法
if(val) {
this.isActive = true
this.$nextTick(async () => {
// 一定要使用nextTick,要不然还没渲染出来,会显示undefined
await this.$refs['loginFormRef'].clearValidate() // 清空校验规则
})
return
}
this.isActive = false
this.$nextTick(async () => {
await this.$refs['registerFormRef'].clearValidate()
})
},