在react项目中打印e.target显示为null解决方案

react 中提示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

在打印前调用: event.persist()  即可。

发布了123 篇原创文章 · 获赞 62 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/qq_37942845/article/details/104293332