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

165
Vistas
scrollintoView not taking component to the top of the page

Below is the home.vue component which has service and legal two other components. In the mounted() I have if id is present? then scrollinto view the legal section. The issue I am facing here is it does scroll a little but doesnt scroll legal section to the top of the page. Attached is the image. Please help me find where I am going wrong

issue

home.vue

<template>
  <div>
    <Service id="service"></Service>
    <br />
    <hr>
    <Legal id="legal"></Legal>
  </div>
</template>

<script>
import Service from 'views/home/service.vue';
import Legal from 'views/legal.vue';

export default {
  components: {
    Service,
    Legal,
  },
  props: ['id'],
  mounted() {
    // this.id == 'legal'
    if (this.id) {
      this.$nextTick(()=> window.document.getElementById('legal').scrollIntoView());
    }
  }
};
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to use querySelector.

mounted(){
    if(this.id){
      const el = this.$el.querySelector("#service");
      if (el) {
        el.scrollIntoView();
      }
    }
  }

codepen - https://codepen.io/Pratik__007/pen/bGrYYZP

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