1.描述
在一个三级路由的页面里添加原生的scroll事件,百度的好多都是在destory事件里销毁,但是不生效,在别的页面scroll事件也是生效的,所以在另外两个生命周期里也加了事件销毁,但是没用。有知道的大佬可以告知下吗
deactivated(){
window.removeEventListener("scroll",this.handleScroll,true);
console.log('现在销毁scroll事件 在deactivaed')
},
beforeDestroy(){
window.removeEventListener("scroll",this.handleScroll,true);
console.log('现在销毁scroll事件')
},
destroyed(){
window.removeEventListener("scroll",this.handleScroll,true);
console.log('现在销毁scroll事件 在destroyed里面')
},
mounted(){
window.addEventListener('scroll',utils._throttle(this.handleScroll),300)
//节流+添加scroll事件
},
2、这是路由的一部分(scroll事件是在skills页面添加的,但是到了infos或者别的页面 依然存在)
{path:'oindex',name:'oindex',component:(resolve)=>require(['@/components/official/oindex'],resolve),
children:[
{path:'infos',name:'infos',component:(resolve)=>require(['@/components/official/infos'],resolve)},
{path:'skills',name:'skills',component:(resolve)=>require(['@/components/official/skills'],resolve)},
{path:'wenyang',name:'wenyang',component:(resolve)=>require(['@/components/official/wenyang'],resolve)},
{path:'theory',name:'theory',component:(resolve)=>require(['@/components/official/theory'],resolve)},