react antd的input,onchange事件,监听event,代码如下:
1 | <Input placeholder= "请输入联系人姓名" maxLength={50} allowClear onChange={onChange} /> |
3 | const onChange = (e) => { |
运行后,出现了下面的错误:
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... ...
原因是,出于性能原因,将重用此合成事件。如果您看到这一点,那么您正在访问已释放/取消的合成事件的属性“target”。设置为空。如果必须保留原始合成事件,请使用event.persist()。有关更多信息,请参见https://fb.me/react-event-pooling
解决办法:
1 | const onChange = (e) => { |
3 | setNameLength(e.target.value.length); |
部分素材资源来源网站,本站提供免费下载,如有侵权请联系站长马上删除!