首页 > 其他 > 详细

"TypeError: Cannot read property 'resetFields' of undefined"

时间:2020-03-03 16:08:03      阅读:981      评论:0      收藏:0      [点我收藏+]

 一个Element 组件库下 Dialog 窗口的 form 组件的 close 事件,触发了 formRef 的 resetFields 方法,报错如下:

[Vue warn]: Error in v-on handler: "TypeError: Cannot read property ‘resetFields‘ of undefined"

found in

---> <ElDialog> at packages/dialog/src/component.vue
       <Anonymous>
         <ElMain> at packages/main/src/main.vue
           <ElContainer> at packages/container/src/main.vue... (1 recursive calls)
             <Home> at src/components/home.vue
               <App> at src/App.vue
                 <Root>

TypeError: Cannot read property ‘resetFields‘ of undefined
at VueComponent.addClose (params.vue?f2b2:258)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.invoker (vue.runtime.esm.js?2b0e:2179)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1854)
at VueComponent.Vue.$emit (vue.runtime.esm.js?2b0e:3888)
at VueComponent.visible (dialog.js?df33:480)
at Watcher.run (vue.runtime.esm.js?2b0e:4568)
at flushSchedulerQueue (vue.runtime.esm.js?2b0e:4310)
at Array.eval (vue.runtime.esm.js?2b0e:1980)
at flushCallbacks (vue.runtime.esm.js?2b0e:1906)

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

但是项目中 formRef 对应的 form 所绑定的数据 ,本来就是前期通过axios查询到的数据做的 :model 绑定,应该不会存在 resetFields 方法触发的时候 对应的 DOM 元素还没加载完的情况,具体原因未知,待确认

 

"TypeError: Cannot read property 'resetFields' of undefined"

原文:https://www.cnblogs.com/anjing529/p/12402256.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!