其他分享
首页 > 其他分享> > vue销毁当前组件的事件监听

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

 

标签:body,vue,documentElement,var,组件,scrollTop,document,监听,scrollHeight
来源: https://www.cnblogs.com/xiaohuohuai/p/14790078.html