vue销毁当前组件的事件监听

mounted(){
        this.loadlist()
        this.userlist()
        this.browserRedirect()
        window.addEventListener("scroll",this.handleFun)
},
destroyed(){
        window.removeEventListener('scroll', this.handleFun);
},
methods:{ handleFun(){ var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; var windowHeight = document.documentElement.clientHeight || document.body.clientHeight; var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; if (scrollTop + windowHeight == scrollHeight) { this.page = this.page+1 this.loadlist() } }, }

 

上一篇:原生textarea模拟移动端微信输入框


下一篇:$(window).scrollTop()与$(dom).offset().top