解决Cannot read properties of undefined (reading ‘resetFields‘)

这篇具有很好参考价值的文章主要介绍了解决Cannot read properties of undefined (reading ‘resetFields‘)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

第一天做项目中遇到了这一个问题关于resetField重置校验报错的问题,

解决Cannot read properties of undefined (reading ‘resetFields‘)

 

然后去网上查找问题的原因,但是找到问题的原因是:
mouted加载table数据以后,隐藏的 Dialog 并没有编译渲染进 dom 里面。所以当通过点击事件,Dialog 弹出的时候,$refs 并没有获取到 dom 元素导致 ‘resetFields’ of undefined,可是不明白为什么用this.$nextTick 将回调延迟到下次DOM更新循环之后执行还是报错?

resetField:对该表单项进行重置,将其值重置为初始值并移除校验结果

问题:无法读取未定义的属性resetFields()

解决:根据Element.ui文档发现

1.确保数据绑定和ref中的字段要一致

:model="ruleForm"

ref="ruleForm"

2.对按钮重置绑定

@click="resetForm('ruleForm')"

3.

 methods: {
    //点击重置按钮,重置登录表单
    resetLoginForm(formName) {
      this.$refs[formName].resetFields();
    }, 
  },

然后看Element.ui文档根据上面终于得到了解决文章来源地址https://www.toymoban.com/news/detail-422675.html

到了这里,关于解决Cannot read properties of undefined (reading ‘resetFields‘)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • TypeError: Cannot read properties of undefined (reading ‘NAME‘)报错解决

    问题描述:前端一个el-table表格,一个医院查询到的科室从后端返回时总是显示不出来,response里面是有数据的,这个表格别的医院都能显示出科室,就那个医院显示不出。报错:TypeError: Cannot read properties of undefined (reading \\\'NAME\\\')  查找问题所在,发现el-table里面有一个:formatte

    2024年02月01日
    浏览(13)
  • 前端解决 TypeError: Cannot read properties of undefined (reading ‘_c‘)

    前端解决 TypeError: Cannot read properties of undefined (reading ‘_c‘)

    每当打开页面包含有这个vue-json-viewer插件的JSON格式文件时,我本地代码运行是正常不报错的,但是线上的就会有报错问题 本地的正常显示   线上的显示,JSON是显示不出来  原因是vue-json-viewer插件的版本有问题,重新下载

    2024年02月08日
    浏览(12)
  • 解决Cannot read properties of undefined (...)类型的报错

    解决Cannot read properties of undefined (...)类型的报错

    场景: 在项目中,想要获取鼠标的元素,红色区域报错:Cannot read properties of undefined (reading \\\'grid3D\\\') 分析: Cannot read properties of undefined类型的报错,一般是报错元素的前一个元素出了问题,也就是this.option没有获取到。 报错类型一般为两种: 对象没值的时候 对象为undefined的时

    2024年02月12日
    浏览(10)
  • 解决 Cannot read properties of undefined类型的报错

    报错类型一般为两种 对象类型 对象没有数据的时候为undefined 这个时候访问内部内容就会报错 举个例子 正常情况 对象有值的时候 var obj={name:‘张三’,age:18} #此时对象有数据访问不会报错 console.log(obj.name) 1 2 3 对象没值的时候 var obj={} console.log(obj.name) #就会报错 Uncaught Syntax

    2023年04月21日
    浏览(7)
  • vue中解决TypeError: Cannot read properties of undefined (reading ‘slice‘)报错

    vue中解决TypeError: Cannot read properties of undefined (reading ‘slice‘)报错

    项目中,因为业务需求通常会在节点中渲染数据,并对数据进行截取 这个时候就可能会在控制台报错 原因是当我们页面刷新数据并没有获取到 解决办法 换成三元表达式就可以解决。

    2024年02月12日
    浏览(15)
  • TypeError: Cannot read properties of undefined (reading ‘NormalModule‘) 错误的解决方案

    这个错误原因各种各样。虽然是相同的错误,但可能造成的原因完全不同。所以还是需要理性分析。 我遇到的原因是我打算在vue3项目(差不多新建的项目)里面添加less功能。于是我执行下面的代码安装less 安装完成后,我打算用一下,结果我忘记webpack怎么配置less了。 在没

    2024年02月16日
    浏览(6)
  • 微信小程序使用jsencrypt进行加密以及解决Cannot read property ‘appName‘ of undefined 和 Cannot read property ‘crypto‘

    微信小程序使用jsencrypt进行加密以及解决Cannot read property ‘appName‘ of undefined 和 Cannot read property ‘crypto‘

    打开微信开发者工具==》顶部导航栏的工具==》构建npm 打开微信开发者工具==》顶部的详情==》本地设置==》允许将js编译成ES5 此时,编译就会出现Uncaught TypeError: Cannot read property ‘appName‘ of undefined 的问题。我查了很多博客解决这个问题。主要是查看了如下的博客 小程序加密

    2024年02月15日
    浏览(42)
  • 错误“Cannot read properties of undefined (reading ‘install‘) at Vue.use” 的解决方案

    错误“Cannot read properties of undefined (reading ‘install‘) at Vue.use” 的解决方案

    项目引入并使用 vue-router 后,浏览器的控制台报如下错误: 错误原因:vue 版本和 vue-router 版本不匹配。         笔者项目是 vue2.7,安装 vue-router 时,直接运行了 npm install vue-router 命令,造成直接下载最新版 vue-router 4.1.6,而 4 以后的版本适用于 vue3.0 版本,用在 vue2.0+

    2024年02月11日
    浏览(6)
  • 解决异步传参时出现 “TypeError: Cannot read properties of undefined (reading‘xxx‘)“这一错误

    异步传参时会出现 “TypeError: Cannot read properties of undefined (reading‘xxx‘)“这一错误 例如:Cannot read properties of undefined (reading ‘id’) 出现该错误的原因是因为花括号中的某些属性未定义。很有可能是因为写错了属性名称 异步请求获取数据时,由于数据时异步获取的,所以一开

    2024年02月11日
    浏览(5)
  • 解决:[Vue warn]: Error in render: “TypeError: Cannot read properties of undefined (reading ‘matched‘)“

    解决:[Vue warn]: Error in render: “TypeError: Cannot read properties of undefined (reading ‘matched‘)“

    在vue项目中使用路由报以下错误: [Vue warn]: Error in render: \\\"TypeError: Cannot read properties of undefined (reading \\\'matched\\\')\\\" ,如图👇 这个错误表示,App组件在渲染过程中尝试访问一个未定义的属性或方法,例如访问一个空对象的属性或调用一个未定义的函数。 出错的代码尝试访问一个叫

    2024年02月12日
    浏览(20)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包