搞不懂,上一个页面可以

换了一个页面,却不行了,后来百度,往后面加了一个true,就ok了…奇了个怪

如下

window.addEventListener('scroll', this.watchScroll, true)

听说es6还有一种写法是这样的

window.addEventListener('scroll', () => {
  let scrollTop = document.documentElement.scrollTop ||
                   document.body.scrollTop ||
                   document.querySelector('.element').scrollTop;
  console.log(scrollTop);
}, true)
下次俺试试

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2022-02-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
  • 2021-08-23
  • 2022-12-23
  • 2022-01-16
  • 2022-12-23
相关资源
相似解决方案