js监听纵向滚动条位置
作者:互联网
// 监听页面滚动
handleScroll () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
if (scrollTop > document.body.clientHeight/2) {
this.showBackTop = true
} else {
this.showBackTop = false
}
},
// 活到顶部按钮
backTop () {
document.body.scrollTop = 0
document.documentElement.scrollTop = 0
// window.pageYOffset = 0 微信浏览器里不支持
}
标签:body,pageYOffset,documentElement,js,滚动条,window,scrollTop,document,监听 来源: https://blog.csdn.net/FUSHENGRUOMENG111/article/details/122621463