Code «Vue Mount Modal to Body» Réponse

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

    
    ...

// 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.

Laisser un commentaire