UNPKG

706 BMarkdownView Raw
1# vuex-router-sync
2
3> Effortlessly keep vue-router and vuex store in sync.
4
5**Note:** requires `vuex>0.6.2`.
6
7### Usage
8
9``` js
10import { sync } from 'vuex-router-sync'
11import store from './vuex/store' // vuex store instance
12import router from './router' // vue-router instance
13
14sync(store, router) // done.
15
16// bootstrap your app...
17```
18
19### How does it work?
20
21- It adds a `route` module into the store, which contains the state representing the current route.
22
23- When the router navigates to a new route, the store's state is updated.
24
25- When the store's `route` state is updated, it notifies the router to navigate to the corresponding path. This enables time-traveling between routes in `vue-devtools`.