[Vuejs]-How to open modal in vue router

1👍

The modal must exists in a component. To show it on route changed, you can use the mounted hook of the component.

<script>
  export default {
    name: 'the-component',
    mounted () {
      this.$modal.showForm('Login)'
    }
  }
</script>

By the way, you can listen to route changed in the layout and fire the dialog when needed:

<script>
  export default {
    name: 'the-layout',

    beforeRouteUpdate () {
      if(this.$route.name === 'xyz'){
        this.$modal.showForm('Login)'
      }
    }
  }
</script>

Leave a comment