UNPKG

598 BJavaScriptView Raw
1import appGlobal from './global'
2
3function createApp (AppClass) {
4 const app = new AppClass()
5 const appConf = {
6 onCreate (options) {
7 appGlobal.$app = this
8 app.$app = this
9 app.$app.$router = app.$router = {
10 params: options
11 }
12 if (app.componentWillMount) {
13 app.componentWillMount()
14 }
15 if (app.componentDidMount) {
16 app.componentDidMount()
17 }
18 },
19
20 onDestroy () {
21 if (app.componentWillUnmount) {
22 app.componentWillUnmount()
23 }
24 }
25 }
26 return Object.assign(appConf, app)
27}
28
29export default createApp