背景:
在使用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();
搞定~