Code: Select all
const router = createRouter({
history: createWebHistory(),
routes: [
// My routes here
],
scrollBehavior(to, from, savedPosition) {
// This is the part that doesn't seem to have any effect.
// I want to always scroll to the top on new navigation.
if (savedPosition) {
return savedPosition;
} else {
return { top: 0 };
}
},
});
Mobile version