Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

133
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda