Skip to content

Instantly share code, notes, and snippets.

@moaoa
Last active September 16, 2023 08:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moaoa/14cf230a652bbd65303cc157d10459dd to your computer and use it in GitHub Desktop.
Save moaoa/14cf230a652bbd65303cc157d10459dd to your computer and use it in GitHub Desktop.
VUE 2 WAY OF HANDLING THE SCROLL BEHAVIOR
const router = new Router({
mode: "history",
routes,
scrollBehavior: (to, from, savedPosition) => {
if (to && to.hash) {
return { selector: to.hash };
} else {
return { x: 0, y: 0 };
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment