Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
caching scroll position on a VUE 3 application

I have a problem with my Vue application. it is a big application with over 40 pages. The problem is sometimes the browser caches the scroll position so when the user moves from a page to another, browser shows the scroll position of the previous page. Which hides the top page content from a user who needs to scroll up to see the full content. This is bad for the user experience.

I found a solution here but it needs to copy/paste in all the 40 pages views which is not very smart. Any better solutions

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Well, using the helpful answer in the linked answer but much more smart, I found a grat method of router called afterEach here is how:


router.afterEach((to, from) => {
 
  window.scrollTo(0, 0);
});

by this code, whenever route changes, the window will scroll back to the top left corner of the browser preventing any cached scroll position and providing a better user experience

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda