Skip to content

Commit ea8e4b7

Browse files
authored
fix: scroll to top when navigate (#151)
1 parent 2145a85 commit ea8e4b7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/main.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ const router = createRouter({
2323
routes: routes,
2424
scrollBehavior(to, from, savedPosition) {
2525
if (to.hash) {
26-
return {
27-
el: to.hash,
28-
behavior: 'smooth'
29-
}
26+
return { el: to.hash, behavior: 'smooth' }
3027
}
28+
return { top: 0, behavior: 'smooth' }
3129
}
3230
})
3331

0 commit comments

Comments
 (0)