diff --git a/index.js b/index.js index 5d164aa..559a51f 100644 --- a/index.js +++ b/index.js @@ -2,15 +2,16 @@ exports.sync = function (store, router) { store.registerModule('route', { state: {}, mutations: { - 'router/ROUTE_CHANGED': function (state, to) { + 'router/ROUTE_CHANGED': function (state, transition) { store.state.route = Object.freeze({ - name: to.name, - path: to.path, - hash: to.hash, - query: to.query, - params: to.params, - fullPath: to.fullPath, - meta: to.meta + name: transition.to.name, + path: transition.to.path, + hash: transition.to.hash, + query: transition.to.query, + params: transition.to.params, + fullPath: transition.to.fullPath, + meta: transition.to.meta, + from: transition.from }) } } @@ -34,12 +35,12 @@ exports.sync = function (store, router) { ) // sync store on router navigation - router.afterEach(function (to) { + router.afterEach(function (to, from) { if (isTimeTraveling) { isTimeTraveling = false return } currentPath = to.fullPath - store.commit('router/ROUTE_CHANGED', to) + store.commit('router/ROUTE_CHANGED', { to: to, from: from }) }) }