<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>所以我的路由器链接正常工作,只是当我到达页面时,我总是在页面的底部,有什么方法可以让它转到链接页面的顶部,这样用户就不用一直向上滚动了,谢谢。
const router = createRouter({
history: createWebHistory(),
routes,
scrollBehavior (to, from, savedPosition) {
return { x: 0, y: 0 };
}
})
export default router;我尝试在路由器javascript中这样做,但仍然在页面的底部。
发布于 2022-05-25 02:04:48
滚动行为备注:此功能仅在浏览器支持history.pushState时才能工作。
试一试
element.scrollTo(x, y);
https://stackoverflow.com/questions/72371192
复制相似问题