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

171
Visualizações
Call the mounted lifecycle again

I currently have a table that uses v-for to populate the data

<table v-for="(data, idx) in dataset" :key="idx">
</table>

Then, I have two buttons that insert or delete certain things in the database after which I would like to re-populate the table to reflect these new changes.

So far, the data is captured from an API that is called in the mounted lifecycle.

mounted: function (){ 
     axios.get(....).then((response => {
           this.dataset = response.data;
     });
}

Hence, is it possible to re-call the mounted function to call the API and thus re-running the v-for?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can just extract your loading logic into a method that can be called from multiple locations:

const Comp = {
  methods: {
    fetchData() {
      axios.get(....).then(response => {
        this.dataset = response.data;
      });
    },
    onSomeOtherAction() {
      // Do stuff.
      this.fetchData();
    },
  },
  mounted() { 
    this.fetchData();
  },
}
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