1const router = createRouter({
2 scrollBehavior(to, from, savedPosition) {
3 // always scroll to top
4 return { top: 0 }
5 },
6})
7
1scrollBehavior (to, from, savedPosition) {
2 if (to.hash) {
3 return {
4 selector: to.hash,
5 behavior: 'smooth',
6 }
7 }
8}
9