<router-link to="/Signuppremium">
<button class="bg-neutral-800 hover:bg-neutral-900 active:bg-neutral-800 text-red-700 hover:text-neutral-400 text-xl w-64 p-4 rounded-xl shadow cursor-pointer inline-block m-10 transition ease-in-out duration-300">Signup</button>
</router-link>
So I have the router-link working alright its just that when I arrive on the page i'm always at the bottom of the page, is there a way I can make it go to the top of the linked page so that the user doesn't have to scroll up all the time, thanks.
const router = createRouter({
history: createWebHistory(),
routes,
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 };
}
})
export default router;
I tried doing this in the router javascript but still goes to the bottom of the page.
Scroll Behavior Note: this feature only works if the browser supports history.pushState.
try
element.scrollTo(x, y);