<script> export default { data(){ return{ i = 0 } }, mounted () { window.addEventListener('scroll', this.handleScroll, true); // 监听(绑定)滚轮 滚动事件 }, methods:{ handleScroll(){ // 页面滚动距顶部距离 var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop var scroll = scrollTop - this.i; this.i = scrollTop; if(scroll<0){ console.log('up') }else{ console.log('down') } }, }