[Vuejs]-How to close a nativescript modal after a few navigations?

2πŸ‘

βœ…

A small improvement could be saving the modal into the Vuex store, accessing it anytime instead of chaining props.

πŸ‘€TomG

1πŸ‘

  1. Detach modal component by plugin.
const modalDialog = {
  install (Vue, options = {}) {
     // ...
  }
}

Vue.use(modalDialog)
  1. Designate Vue prototype for plugin.
const modalDialog = {
  install (Vue, options = {}) {
     Vue.prototype.$modal = {
       show () {
         // ...
       },
       hide () {
         // ..
       }
     }
  }
}

Vue.use(modalDialog)
  1. this.$modal is accessible from all components.
this.$modal.show() // or hide()
πŸ‘€Dev.DY

Leave a comment