Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

169
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!