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

204
Views
Cómo agregar animación css a vue.js cuando se realiza una llamada a la API

Estoy usando un ícono y estoy haciendo una llamada a la API cuando se hace clic en él:

 <i class="fas fa-sync" @click.prevent="updateCart(item.id, item.amount)"></i>

Así que quiero activarlo con animación hasta que se complete la llamada a la API o durante dos segundos. Pero no estoy seguro de cómo hacerlo, así que si pudiera darme una solución, sería genial.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Simplemente puede alternar una animación CSS (o la clase que ejecuta la animación), por ejemplo, usando:

 const MyIcon = Vue.extend({ template: ` <i class="fas fa-sync" :style="(loading ? 'animation: spin 1s infinite;' : '')" @click.prevent="updateCart"></i> `, data() { return { loading: false, } }, methods: { updateCart() { this.loading = true // Do your stuff here and set to false when you're done setTimeout(() => this.loading = false, 2000) } } })

Donde el giro podría ser algo como:

 @keyframes spin { from { transform: rotateZ(0deg) } to { transform: rotateZ(360deg) } }
over 4 years ago · Santiago Trujillo 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!