Cannot read property 'resetFields' of undefined 问题及引申
问题描述: 使用element开发我的后台系统,编辑和新增使用了同一个弹出框
<el-dialog><el-form></el-form></el-dialog>
绑定了数据data里的commentForm对象
为了在新增弹出框清空表单, 使用了this.$refs[formName].resetFields()
每次第一次点击新增显示弹出框,都会报错
"[Vue warn]: Error in event handler for "click": "TypeError: Cannot read property 'resetFields' of undefined""
解决办法(转载于@以梦为马papapa)的博客:

浙公网安备 33010602011771号