Synchronizing the store and the router

We can integrate the router into the store with the official vuex-router-sync package. It will expose the current route in the state (state.route) and will commit a mutation each time the route changes:

  1. Install it with the usual command:
      npm i -S vuex-router-sync
  1. To use it, we need the sync method in the main main.js file:
      import { sync } from 'vuex-router-sync'

sync(store, router)

Now, you can access the state.route object and time-travel debugging will apply to the router as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.156.140