first
This commit is contained in:
29
node_modules/vant/es/mixins/bind-event.js
generated
vendored
Normal file
29
node_modules/vant/es/mixins/bind-event.js
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Bind event when mounted or activated
|
||||
*/
|
||||
import { on, off } from '../utils/dom/event';
|
||||
var uid = 0;
|
||||
export function BindEventMixin(handler) {
|
||||
var key = "binded_" + uid++;
|
||||
|
||||
function bind() {
|
||||
if (!this[key]) {
|
||||
handler.call(this, on, true);
|
||||
this[key] = true;
|
||||
}
|
||||
}
|
||||
|
||||
function unbind() {
|
||||
if (this[key]) {
|
||||
handler.call(this, off, false);
|
||||
this[key] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
mounted: bind,
|
||||
activated: bind,
|
||||
deactivated: unbind,
|
||||
beforeDestroy: unbind
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user