Vue Router Return to Last Position or Top

December 15, 2019
const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.