Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
How do I make this javascript function work?

When a button is clicked, I want it to scroll to the h2 of the other component (but they're all on the same page). Getting an error here, how to make this work?

 <script setup>
 import { scroll } from "quasar";
 const { getScrollTarget, setVerticalScrollPosition } = scroll;

 function scrollToElement(el) {
 const el = h2;
 const target = getScrollTarget(el);
 const offset = el.offsetTop;
 const duration = 1000;
 setVerticalScrollPosition(target, offset, duration);
 }
</script>

<template>
<h1 class="q-mx-md text-weight-medium text-primary">
 </h1>
<q-btn
  class="bg-primary text-white q-mx-lg cursor-pointer"
  size="lg"
  @click="scrollToElement(el)"
>
/></q-btn>`

And this is the other component:

<template>
<section class="q-pt-md scroll">
<div class="row items-center relative-position">
  <h2 class="q-ml-md text-weight-medium">
    {{ title }}
  </h2>
</div>
</section>
</template>`
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda