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() } }, }

 

posted @ 2021-05-20 15:43  小灬壊  阅读(4033)  评论(0编辑  收藏  举报