So I configured the rouse.scrollBehaviour.ts file in Nuxt 3. as follows:
import { defineNuxtPlugin } from "#app"; export default defineNuxtPlugin((nuxtApp) => { nuxtApp.$router.options.scrollBehavior = (to, from, savedPosition) => { if (savedPosition) { return savedPosition; } return { left: 0, top: 0, behaviour: "smooth" }; }; });
The problem is I think it's scrolling earlier than the page loads, so there's a weird jumping effect on the page.
Here is a video of the issue: https://user-images.githubusercontent.com/22452368/154849559-3974fc01-e265-486b-865b-55ee03053fa8.mp4
Can you help me see what's wrong here? Or is there a bug in Nuxt 3?
P粉6961462052024-03-26 13:12:12
You can try the solution mentioned in nuxt question< /p>
// app/router.options.js export default { scrollBehavior() { return { top: 0 } }, }