Skip to content

Commit 5525b23

Browse files
committed
move initEvent function into the eventMixin class
1 parent 29ee158 commit 5525b23

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/core/event/index.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ export function eventMixin(Base = class {}) {
2525
sidebar.getAndActive(this.router, 'nav');
2626
}
2727
}
28-
};
29-
}
3028

31-
export function initEvent(vm) {
32-
// Bind toggle button
33-
sidebar.btn('button.sidebar-toggle', vm.router);
34-
sidebar.collapse('.sidebar', vm.router);
35-
// Bind sticky effect
36-
if (vm.config.coverpage) {
37-
!isMobile && on('scroll', sidebar.sticky);
38-
} else {
39-
body.classList.add('sticky');
40-
}
29+
initEvent() {
30+
// Bind toggle button
31+
sidebar.btn('button.sidebar-toggle', this.router);
32+
sidebar.collapse('.sidebar', this.router);
33+
// Bind sticky effect
34+
if (this.config.coverpage) {
35+
!isMobile && on('scroll', sidebar.sticky);
36+
} else {
37+
body.classList.add('sticky');
38+
}
39+
}
40+
};
4141
}

src/core/init/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import config from '../config';
2-
import { initEvent } from '../event';
32
import { initFetch } from '../fetch';
43

54
export function initMixin(Base = class {}) {
@@ -12,7 +11,7 @@ export function initMixin(Base = class {}) {
1211
this.callHook('init');
1312
this.initRouter(); // Add router
1413
this.initRender(); // Render base DOM
15-
initEvent(this); // Bind events
14+
this.initEvent(); // Bind events
1615
initFetch(this); // Fetch data
1716
this.callHook('mounted');
1817
}

0 commit comments

Comments
 (0)