Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

vue mount modal to body

// If you're really, really desperate:

// 1. In your root Vue instance
new Vue({ data() { return { currentModal: null } } });
// 2. Bind the component in the template
<body id='app'>
    <component v-if="currentModal" :is="currentModal"></component>
    ...
</body>
// 3. Render anything you want programmatically from other components
// Inside every component you have access to the root instance with this.$root.
this.$root.currentModal = 'my-component'

// You might want to add another prop like `currentModalProps` to pass data to it.
// Not easy to get data back from the component I think.
// This is a Hail Mary attempt to get this working.
Source by vuejs.org #
 
PREVIOUS NEXT
Tagged: #vue #mount #modal #body
ADD COMMENT
Topic
Name
7+3 =