Vue switch route page back to the top
First
//Jump back to top router.afterEach((to,from,next) => { window.scrollTo(0,0); })
Second
router.beforeEach(function(to, from, next) { window.scrollTo(0, 0) next() }) })
Third
////////Put it inside export default new Router({ scrollBehavior (to, from, savedPosition) { if (savedPosition) { return savedPosition } else { return { x: 0, y: 0 } } } })
comment
-
Hello, I didn't succeed