FrontendDeveloper.in

Vue.js question detail

How do you sync current route in vuex store?

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
  1. 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
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399