Handling scrollBehavior #263
Unanswered
wilfredinni
asked this question in
Q&A
Replies: 2 comments
-
Never mind, I just added this to const router = useRouter()
router.options.scrollBehavior = (to, _from, savedPosition) => {
if (savedPosition) return savedPosition
if (to.hash) return { el: to.hash, behavior: 'smooth' }
else return { top: 0 }
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
You can setup this when creating vue router instance. https://router.vuejs.org/guide/advanced/scroll-behavior.html |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! How would you handle scrollBehavior with vite-plugin-pages. I need to scroll to top if there is no hash, otherwise, to the hash. Thank you!
Beta Was this translation helpful? Give feedback.
All reactions