Skip to content
Discussion options

You must be logged in to vote

scrollBehavior third argument stores the saved scrolling position.

You can use it to do the following:

scrollBehavior(_to, _from, savedPosition) {
  return savedPosition || { top: 0 }
}
  • If you are navigating to a new page, savedPosition is null so it will scroll to the top
  • If you are using the back or forward browser button, savedPosition is used instead

This is described on this page, written in a slightly different (but equivalent) way: https://router.vuejs.org/guide/advanced/scroll-behavior.html

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ylli2000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants