Cannot read property 'clearValidate' of undefined
程序员文章站
2022-06-07 12:36:05
...
这个错误是因为你的dom元素还没有加载完,你就想使用resetFields置空。也就是你写的this.$refs['addForm'].resetFields();这个里面的addForm还没有加载出来呢。
解决:nextTick()
Vue.nextTick
用于延迟执行一段代码
详细讲解:https://www.jianshu.com/p/a7550c0e164f
this.$nextTick(()=>{
this.$refs['addForm'].clearValidate();
})
推荐阅读
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object
-
npm ERR! Cannot read property 'path' of null
-
js报错 Cannot read property 'getAttribute' of null
-
微信小程序报Cannot read property 'setData' of undefined的错误
-
webpack报错Cannot read property 'presetToOptions' of undefined
-
Extjs4---Uncaught TypeError: Cannot read property ‘items’ of undefined
-
JavaScript Uncaught TypeError: Cannot read property 'value' of null
-
Cannot read property 'tap' of undefined
-
Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#
-
el-tooltip组件中content使用Vue-i18n报错TypeError: Cannot read property ‘$t‘ of null