const router = new VueRouter({
mode: "history",
routes: defaultRoutes,
scrollBehavior(to, from, savedPosition) {
return { x: 0, y: 0 }
},
});
특정 컴포넌트는 기억하고 싶을 때
const router = new VueRouter({
mode: "history",
routes: defaultRoutes,
scrollBehavior(to, from, savedPosition) {
if (to.name === 'Home') {
return savedPosition;
} else {
return { x: 0, y: 0 }
}
},
});