Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

160
Views
la función vue no se ejecuta después de montar ()

Estoy creando un juego de memoria, me gustaría comenzar inmediatamente después de que se cargue la página.

Para empezar, necesito createDeck() y showCards()

Probé varias cosas en el valor predeterminado de exportación {} como:

 created(){ this.createDeck(), this.createShowCards() },

y

 mounted() { this.fetchCards(), // also need to fetch the cards, this works ok... this.createDeck(), this.createShowCards() console.log('component mounted') },

Puedo hacer que el juego funcione al llamar a las funciones de inicio con un botón de inicio:

 <div class="text-center"> <button @click="startGame()" v-if="Object.keys(cards).length != 0">Start game</button> </div>

¿Alguien puede explicarme lo que me estoy perdiendo? ¿Cómo puedo obtener el "botón para hacer clic automáticamente"?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente esperar a que se carguen las tarjetas:

 async mounted() { await this.fetchCards() this.createDeck() this.createShowCards() },

y tal vez necesites hacer que esa función sea asíncrona como

 async fetchCards() { await ...}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!