how to Install plugin but not createApp? #6227
              
                Unanswered
              
          
                  
                    
                      uCloudCastle
                    
                  
                
                  asked this question in
                Help/Questions
              
            Replies: 1 comment
-
|  | 
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
In Vue2 we have a plugin use like that:
import Plugin from 'aviana-plugin-vue' Vue.use(Plugin, { ...config, createRouter: root => { return new Router({ routes: Plugin.buildRoutes(routes, root), }) }, createInstance: (container, router) => { return new Vue({ router: router, store: store, render: h => h(App), }).$mount(container ? container.querySelector('#app') : '#app') }, })as the code snippet,we didn't create vue app in main.ts,Instead we deliver "createInstance" function to the plugin so it can create instance in suitable time。
In Vue3 we try this way:
import Plugin from 'aviana-plugin-vue' const app = createApp(App) // wrong but we need the “app.use” app.use(Plugin, { ...config, createRouter: (root) => { return createRouter({ history: createWebHashHistory(), routes: Plugin.buildRoutes(routes, root), }) }, createInstance: (container: any, router: any) => { // const app = createApp(App) // it should be here app.use(store) app.use(router) app.mount(container ? container.querySelector('#app') : '#app') return app }, })But this is contrary to our expectation,this instance should not be created so early。so how to Install plugin but not createApp,just like Vue2 did?
Beta Was this translation helpful? Give feedback.
All reactions