Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在反应中处理页面滚动事件的更好做法是什么?
A.addEventListener()在所有组件中都需要页面滚动事件
addEventListener()
B、创建一个组件作为页面的包装器,使用onScroll处理事件
C. 还有其他更好的方法吗?
如果要观察屏幕中是否有元素,也可以使用Intersection Observer API 。