Cannot read property 'clearValidate' of undefined

Cannot read property 'clearValidate' of undefined

这个错误是因为你的dom元素还没有加载完,你就想使用resetFields置空。也就是你写的this.$refs['form'].resetFields();这个里面的form还没有加载出来呢。

Vue.nextTick用于延迟执行一段代码

this.$nextTick(()=>{
   this.$refs['form'].clearValidate();
})

posted @ 2023-08-27 14:37  菜鸟辉哥  阅读(43)  评论(0编辑  收藏  举报