@@ -15,6 +15,9 @@ const HOOK_KEYS: { [index: string]: boolean } = Object.freeze({
1515 onError : true
1616} )
1717
18+ const defaultAppComponent = { name : 'app' , render : ( h : any ) => h ( 'router-view' ) }
19+ const defaultAppElement = '#app'
20+
1821function addVuexModules ( modular : Modular ) {
1922 const application = modular . getApplication ( )
2023 const vuexAlong : any = {
@@ -137,23 +140,26 @@ function addRouterHooks(modular: Modular) {
137140}
138141
139142function createVueInstance ( modular : Modular ) {
140- // 处理 vue.app
141- const app = modular . getExtension ( 'vue.app' )
142- const component = app . component || { name : 'app' , render : ( h : any ) => h ( 'router-view' ) }
143- const options : any = {
144- router,
145- store,
146- render : ( h : any ) => h ( component )
147- }
148- // 处理 vue.options
149- const vueOptions = modular . getExtension ( 'vue.options' )
150- if ( vueOptions !== null ) {
151- options . mixins = vueOptions
152- }
153- const vm = new Vue ( options )
154- const element : string = app . element || '#app'
155- vm . $mount ( element )
156- modular . setAttribute ( 'vue.instance' , vm )
143+ // 处理 vue.app
144+ let app = modular . getExtension ( 'vue.app' )
145+ if ( app === undefined ) {
146+ app = { component : defaultAppComponent , element : defaultAppElement }
147+ }
148+ const component = app . component || defaultAppComponent
149+ const options : any = {
150+ router,
151+ store,
152+ render : ( h : any ) => h ( component )
153+ }
154+ // 处理 vue.options
155+ const vueOptions = modular . getExtension ( 'vue.options' )
156+ if ( vueOptions !== null ) {
157+ options . mixins = vueOptions
158+ }
159+ const vm = new Vue ( options )
160+ const element : string = app . element || defaultAppElement
161+ vm . $mount ( element )
162+ modular . setAttribute ( 'vue.instance' , vm )
157163}
158164
159165const activator : Activator = {
0 commit comments