Open a Vuetify dialog from a component template in VueJS

前端 未结 8 1427
故里飘歌
故里飘歌 2020-12-02 11:27

I\'m using the VueJS Vuetify framework and I need to open a dialog - that gets imported as a component template - from another template. Once the Menu butto

8条回答
  •  时光说笑
    2020-12-02 12:05

    You can open the dialog using custom events and using an event bus for non parent-child communication.

    If your application gets a bit more complex I recommend you use Vuex for state management.


    Event bus solution:

    In your main.js or in a new file create and export a new Vue instance :

    export const bus = new Vue()

    In app.vue import the busand emit the event:

    
    
    
    

    In modal.vue also import the bus and listen for the event in the created hook:

    
    

提交回复
热议问题