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

231
Visualizações
How to go automatically at the bottom of a page without scrolling down when a new div appears in Vue application styled with Tailwind?

In my Nuxt/Vue application with Tailwind, by clicking on one element I am uncovering the next element. It works fine but the user needs to scroll down to see the new element. How can I make my app to go straight away to the bottom of the page to see the new element without scrolling down ??

<template>
  <div @click="onClick">
    <Element/>
  </div>
  <div v-if="Section > 0" @click="onClick">
    <Element/>
  </div>
  <div v-if="Section > 1" @click="onClick">
    <Element/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Section: 0
    }
  },
  methods: {
    onClick() {
      this.Section++
    }
</script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can do it by referencing the divs and then using window.scrollTo to scroll to them (or at the bottom of the page).

Just an example of how you can do it (your code modified):

<template>
  <div @click="onClick('section0')" ref="section">
    <Element/>
  </div>
  <div v-if="Section > 0" ref="section0" @click="onClick('section1')">
    <Element/>
  </div>
  <div v-if="Section > 1" ref="section1" @click="onClick('nextSectionRef')">
    <Element/>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Section: 0
    }
  },
  methods: {
    onClick(refName) {
      this.Section++;

      var element = this.$refs[refName];
      var top = element.offsetTop;

      window.scrollTo(0, top);
    }
</script>

This will help you to understand it better: https://shouts.dev/vuejs-scroll-to-elements-on-the-page

This also might answer your question: Scroll to bottom of div with Vue.js

about 4 years ago · Juan Pablo Isaza Relatório
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