Dex-chan lover
- Joined
- Apr 7, 2018
- Messages
- 443
Every time I click on an internal link, something like next or previous chapter, or from comic to chapter, the scrolling bar will try to resume from the previous page position.
I have used Nuxt 3 and I know this is an issue in router
I would suggest using something like below code
I have used Nuxt 3 and I know this is an issue in router
I would suggest using something like below code
JavaScript:
//in default layout or app.vue
const route = useRoute();
const oldPath = ref(route.path);
const react = reactive({ oldPath });
watch(route, (newRoute) => {
if (oldPath.value !== newRoute.path) {
document.scrollingElement.scrollTo(0,0)
react.oldPath = newRoute.path;
}
});
Upvote
0