[Vuejs]-Close the previous v-dialog when i move to next v-dialog

0👍

If those dialogs are in different components, eventBus maybe the best way to communicate between non-parent-child components:

  1. in "main.js":
new Vue({
    data: {
        eventHub: new Vue()
    },
    ...
}).$mount("#app")
  1. in your dialog component, or the component that contain the dialog:
created() {    
    this.$root.eventHub.$on("close-dialog", () => {
        do something to close your dialog, such as this.visible = false
    })
}
  1. before open your new dialog:
this.$root.eventHub.$emit("close-dialog")

Leave a comment