Skip to content

Commit 3232eac

Browse files
predhmeyyx990803
authored andcommitted
[29] Store 'from' in state.route (#36)
1 parent 7a269fe commit 3232eac

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ exports.sync = function (store, router) {
22
store.registerModule('route', {
33
state: {},
44
mutations: {
5-
'router/ROUTE_CHANGED': function (state, to) {
5+
'router/ROUTE_CHANGED': function (state, transition) {
66
store.state.route = Object.freeze({
7-
name: to.name,
8-
path: to.path,
9-
hash: to.hash,
10-
query: to.query,
11-
params: to.params,
12-
fullPath: to.fullPath,
13-
meta: to.meta
7+
name: transition.to.name,
8+
path: transition.to.path,
9+
hash: transition.to.hash,
10+
query: transition.to.query,
11+
params: transition.to.params,
12+
fullPath: transition.to.fullPath,
13+
meta: transition.to.meta,
14+
from: transition.from
1415
})
1516
}
1617
}
@@ -34,12 +35,12 @@ exports.sync = function (store, router) {
3435
)
3536

3637
// sync store on router navigation
37-
router.afterEach(function (to) {
38+
router.afterEach(function (to, from) {
3839
if (isTimeTraveling) {
3940
isTimeTraveling = false
4041
return
4142
}
4243
currentPath = to.fullPath
43-
store.commit('router/ROUTE_CHANGED', to)
44+
store.commit('router/ROUTE_CHANGED', { to: to, from: from })
4445
})
4546
}

0 commit comments

Comments
 (0)