0 votes
in VueJS by
How do you sync current route in vuex store?

1 Answer

0 votes
by

You can use vue-router-sync library to sync current $route object in vuex store's state.

The usage is quite straight forward with two steps

  1. Installation:
    npm install vuex-router-sync
  2. Sync router and store:
    import { sync } from 'vuex-router-sync'
    import store from './vuex/store' // vuex store instance
    import router from './router' // vue-router instance
    
    const unsync = sync(store, router) // Returns an unsync callback function
    unsync() // Unsyncs store from router

Related questions

0 votes
asked Sep 7, 2023 in VueJS by AdilsonLima
0 votes
asked Sep 9, 2023 in VueJS by DavidAnderson
...