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

302
Visualizações
Losing data (Datatable) on a browser refresh in Vue.js

I'm trying to display data in Datatable with vuejs. What I do is that I fetch the data in store and I send it to the component to display it by Datatable. First time it works after that when I reload the page I lose all data and the table shows me that there is no data to show I don't know why. Thanks for helping me :) That's the code:

<template>
  <div class="content">
    <table id="studyLevelTable" class="studyLevelTable display table-bordered nowrap" style="width: 100%">
      <thead>
      <tr>
        <th scope="col">#Id</th>
        <th scope="col">Nom</th>
        <th scope="col">Created At</th>
        <th scope="col">Updated At</th>
        <th scope="col">Is Deleted</th>
        <th scope="col">Action</th>
      </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
  </div>
</template>

<script>
import {mapGetters} from "vuex";

export default {
  name: "displayStudyLevels",
  data: function () {
    return {
      dataTable:null,
    }
  },
  computed: {
    ...mapGetters(["getAllStudyLevels"]),
  },
  methods: {
  },
  mounted() {
    console.log("app mounted");
    this.$store.dispatch("getStudyLevels");
      this.dataTable = $('.studyLevelTable').DataTable({
        language: {
          emptyTable: "No Results Found"
        }
      });
    this.getAllStudyLevels.forEach(studyLevel=>{
      this.dataTable.row.add([
        studyLevel.id,
        '<a href="#">'+studyLevel.name+'</a>',
        studyLevel.createdAt,
        studyLevel.updatedAt,
        studyLevel.is_deleted,
        '<button class="updateButton" @click="submit">Update</button>'
      ]).draw(false)
    })
  }
}
</script>
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