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 Tue, Mar 21, 2023
Mag
Stefan Huber
Olga Bulat
Maciek Palmowski
Sébastien Chopin
Daniel Roe
Clément Ollivier
Paiva
Florian Reuschel
Rishi Raj Jain
Savas Vedova
Steven Soekha
Vinícius Alves
Kareem Dabbeet
Valentín Costa
Ryan Skinner
Alex Hirzel
Ajeet Chaulagain
René Eschke
Nico Devs
Muhammad
Nazaré da Piedade
Naoki Hamada
Tom
Yann Aufray
Anthony Chu
Nuzhat Minhaz
Lucas Portet
Richard Schloss
bpy
Antony Konstantinidis
Hibariya
Jose Seabra
Eze
Florian LEFEBVRE
Lucas Recoaro
Julien SEIXAS
Hugo
Sylvain Marroufin
Spencer Cooley
Piotr Zatorski
Vladimir Semenov
Harry Allen
kazuya kawaguchi
Unai Mengual
Hyunseung
Alexandre Chopin
pooya parsa
Nick Medrano
Mosaab Emam
Ilja
Heitor Ramon Ribeiro
Nero
Yoon Han
Ikko Eltociear Ashimine