加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用antd开发时遇上的onChange event为空的问题

发布时间:2020-12-15 06:28:05 所属栏目:百科 来源:网络整理
导读:背景: 在使用React进行前端页面的开发,使用antd的Input组件时,本想利用onChange事件的event.target.value获取正在修改的值,但是一直报错为空,下面是控制台的报错信息: This synthetic event is reused for performance reasons. If you’re seeing thi

背景:

在使用React进行前端页面的开发,使用antd的Input组件时,本想利用onChange事件的event.target.value获取正在修改的值,但是一直报错为空,下面是控制台的报错信息:

This synthetic event is reused for performance reasons. If you’re seeing this,you’re accessing the property target on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around,use event.persist(). See https://fb.me/react-event-pooling for more information.

解决方法:
在操作event之前,先写如下语句:

e.persist();

搞定~

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读