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

127
Visualizações
Vue Js Preloader wont stop displaying even when components load

In my app, my preloader icon doesnt seem to go away when I click on a button which redirects to a new page. Since I am new to Vue, what could I possibly do to be able to have the icon go away once the page rerenders?

<template>
  <div class="page-loader" v-if="!isloaded">
    <div class="cube"></div>
    <div class="cube"></div>
    <div class="cube"></div>
    <div class="cube"></div>
  </div> 
</template>

<script>
  export default {
    data: () => {
      return {
        isloaded: false
      }
    },
    mounted() {
      document.onreadystatechange = () => {
        if (document.readyState == "complete") { 
          this.isloaded = true;
        } 
      }
    },
  }
</script>

the mounted seems to work initially but then after that it doesnt work once redirecting on the page?

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

0

I think you don't need the onreadystatechange as the completed ready state isn't related if the data has been fetched or not, To stop the preloader after fetching data from API, It would use the created lifecycle.

Ex:

data() {
    return {
        isloaded: false,
        data: null,
    }
},
async created() {
     // any fetch method ( fetch or axios )
     const response = await fetch('API_URL')
     const data = await response.json()
     // set the data
     this.data = data;
     // here we ensure that data fetched, we can stop preload
     this.isloaded = true;
},
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