2π
β
A small improvement could be saving the modal into the Vuex store, accessing it anytime instead of chaining props.
π€TomG
1π
- Detach modal component by plugin.
const modalDialog = {
install (Vue, options = {}) {
// ...
}
}
Vue.use(modalDialog)
- Designate Vue prototype for plugin.
const modalDialog = {
install (Vue, options = {}) {
Vue.prototype.$modal = {
show () {
// ...
},
hide () {
// ..
}
}
}
}
Vue.use(modalDialog)
this.$modal
is accessible from all components.
this.$modal.show() // or hide()
π€Dev.DY
Source:stackexchange.com