Skip to content

Commit cfd1a98

Browse files
committed
refactor: add smooth scroll when a route is changed
1 parent 0712ea9 commit cfd1a98

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/router/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ const routes = [
293293
const router = createRouter({
294294
history: createWebHashHistory(process.env.BASE_URL),
295295
routes,
296+
scrollBehavior() {
297+
// always scroll to top
298+
return { top: 0 }
299+
},
296300
})
297301

298302
export default router

0 commit comments

Comments
 (0)