Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue-滚动 #36

Open
wohaofang opened this issue Jul 31, 2020 · 0 comments
Open

vue-滚动 #36

wohaofang opened this issue Jul 31, 2020 · 0 comments

Comments

@wohaofang
Copy link
Owner


利用VUE写一个在控制台打印当前的scrollTop,

首先,在mounted钩子中给window添加一个滚动滚动监听事件,

mounted () {
  window.addEventListener('scroll', this.handleScroll)
},
然后在方法中,添加这个handleScroll方法
handleScroll () {
  var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
  console.log(scrollTop)
},


友情链接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant