关于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);
},