Using application context in detached component? #13585
              
                Unanswered
              
          
                  
                    
                      rockisch
                    
                  
                
                  asked this question in
                Help/Questions
              
            Replies: 1 comment 1 reply
-
| 
 So the best you can do is to encapsulate all of that app setup code in a function so that you can use it here as well: // myApp.js
import { createApp } from 'vue'
export function createMyApp(AppComponent) {
  const app = createApp(AppComponent)
  app.use(...) // add plugins, global components etc here
  return app
}Then use that function to mount your main app in you main.js file, and also use it to mount that small separate app in your  | 
Beta Was this translation helpful? Give feedback.
                  
                    1 reply
                  
                
            
  
    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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I'm trying to build a modal 'detached component', but I'm having a hard time ensuring it 'inherits' the app context from the called component. With 'app context' I mean directives/provides/plugins.
Here's an example:
This obviously doesn't work because the vnode created inside
showModaldoes not have the app context needed to accessfoo. Is there a easy way to do this without creating 'a separate app' withcreateAppand re-configuring all directives/provides/plugins?Beta Was this translation helpful? Give feedback.
All reactions