[improvement] Tab: optimize event binding (#3512)

This commit is contained in:
neverland
2019-06-14 16:50:37 +08:00
committed by GitHub
parent 6e30dcb1d0
commit c05124b3ec
2 changed files with 32 additions and 52 deletions

View File

@@ -3,14 +3,14 @@ import { on, off } from '../utils/dom/event';
export function BindEventMixin(handler) {
function bind() {
if (!this.binded) {
handler.call(this, on);
handler.call(this, on, true);
this.binded = true;
}
}
function unbind() {
if (this.binded) {
handler.call(this, off);
handler.call(this, off, false);
this.binded = false;
}
}
@@ -18,7 +18,7 @@ export function BindEventMixin(handler) {
return {
mounted: bind,
activated: bind,
destroyed: unbind,
deactivated: unbind
deactivated: unbind,
beforeDestroy: unbind
};
}