您可以
el.getBoundingClientRect().bottom用来检查底部是否已被查看
isBottom(el) { return el.getBoundingClientRect().bottom <= window.innerHeight;}componentDidMount() { document.addEventListener('scroll', this.trackScrolling);}componentWillUnmount() { document.removeEventListener('scroll', this.trackScrolling);}trackScrolling = () => { const wrappedElement = document.getElementById('header'); if (this.isBottom(wrappedElement)) { console.log('header bottom reached'); document.removeEventListener('scroll', this.trackScrolling); }};


