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() } }, }
原文地址:https://www.cnblogs.com/xiaohuohuai/p/14790078.html