The scrollToTop property
The scrollToTop
property lets you tell Nuxt to scroll to the top before rendering the page.
-
Type:
Boolean
(default:false
)
By default, Nuxt scrolls to the top when you go to another page, but with children routes, Nuxt keeps the scroll position. If you want to tell Nuxt to scroll to the top when rendering your child route, set scrollToTop
to true
:
<template>
<h1>My child component</h1>
</template>
<script>
export default {
scrollToTop: true
}
</script>
Conversely, you can manually set scrollToTop
to false
on parent routes as well.
If you want to overwrite the default scroll behavior of Nuxt, take a look at the scrollBehavior option .
Edit this page on GitHub
Updated at Mon, Aug 19, 2024
Sébastien Chopin
Nazaré da Piedade
Nobu
川音리오
Maciek Palmowski
Nestor Vera
Daniel Roe
Yue Yang
Jeronimas
Clément Ollivier
Alexander Lichter
N3-rd
Adrien Zaganelli
Mag
Stefan Huber
Olga Bulat
Paiva
Florian Reuschel
Savas Vedova
HIJACK
Vinícius Alves
Kareem Dabbeet
Valentín Costa
Ryan Skinner
Alex Hirzel
Ajeet Chaulagain
René Eschke
Nico Devs
Muhammad
Naoki Hamada
Tom
Yann Aufray
Anthony Chu
Nuzhat Minhaz
Lucas Portet
Richard Schloss
Bobby
bpy
Antony Konstantinidis
Hibariya
Jose Seabra
Eze
Florian Lefebvre
Lucas Recoaro
Julien SEIXAS