前端-全栈

关于addEventListener和removeEventLi

2021-09-27  本文已影响0人  光明程辉
window.addEventListener('message', this.myFunction, true);
// 自己的函数
myFunction(e) { 
   let eData = e.data;
   // todo 
 },

// 移除 -- 不能使用匿名函数!!!
  beforeDestroy() {
    window.removeEventListener('message', this.myFunction, true);
  },
上一篇 下一篇

猜你喜欢

热点阅读