Skip to content

Commit fdc6fdf

Browse files
JounQinyyx990803
authored andcommitted
Avoid calling replace on initial render, fix #71 (#72)
1 parent 06876f5 commit fdc6fdf

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ exports.sync = function (store, router, options) {
1818
var storeUnwatch = store.watch(
1919
function (state) { return state[moduleName] },
2020
function (route) {
21-
if (route.fullPath === currentPath) {
22-
return
21+
var fullPath = route.fullPath
22+
if (fullPath === currentPath) { return }
23+
if (currentPath != null) {
24+
isTimeTraveling = true
25+
router.push(route)
2326
}
24-
isTimeTraveling = true
25-
var methodToUse = currentPath == null
26-
? 'replace'
27-
: 'push'
28-
currentPath = route.fullPath
29-
router[methodToUse](route)
27+
currentPath = fullPath
3028
},
3129
{ sync: true }
3230
)

0 commit comments

Comments
 (0)