I have just came across this problem too and I thought there is a little space to optimize the page swap. In my case I'd like to make a smooth transition instead of "jumping arround". I've already required in jQuery as alias for $.
Here is my Router Setup for the smooth animation, feel free to modify the lines to your needs accordingly. This code could been made cleaner but should be fine enough to show you the working idea.
// Register Router and Paths
const router = new VueRouter({
mode: 'history',
routes : [
{ path: '/aboutme/', component: index, name:'me.index'},
{ path: '/aboutme/cv', component: cv, name:'me.cv' }
],
// Build smooth transition logic with $
scrollBehavior (to, from, savedPosition) {
if (to.hash) {
return $('html,body').stop().animate({scrollTop: $(to.hash).offset().top }, 1000);
} else {
return $('html,body').stop().animate({scrollTop: 0 }, 500);
}
}
})
Side Question on my side: Do we have to return anything? I don't have any trouble with or without returning due the jQuery Animation is handling the page scroll.
regards Gkiokan