首先添加监听事件
window.addEventListener('scroll', this.handleScroll)
事件处理
handleScroll() { var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop var visheight = document.body.offsetHeight var allheight = this.$refs.pdfWrap.clientHeight if (allheight - visheight - scrollTop <= 800) { this.showGif = false } }
页面销毁后处理
beforeDestroy() { window.removeEventListener('scroll', this.handleScroll) }
标签:vue,滚动,handleScroll,window,var,scrollTop,document,监听 From: https://www.cnblogs.com/sgdkg/p/16955452.html