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

295
Views
Actualizar el texto del botón cuando se hace clic en él

Estoy tratando de hacer que esta aplicación funcione :

ingrese la descripción de la imagen aquí

Quiero hacer que el botón con número cambie su número cuando se hace clic en + o - , pero no sé cómo. Aquí está el código (soy nuevo en esto, así que lo siento si el código te parece terrible):

HTML del botón :

 <div class="btn-group" role="group" aria-label="Basic example" v-bind='food' style="float: right"> <button type="button" class="btn btn-primary">{{food.number}}</button> <button type="button" class="btn btn-primary" v-on:click="increase(food.id)">+</button> <button type="button" class="btn btn-primary" v-on:click="decrease(food.id)">-</button> </div>

aplicación.js :

 const App={ methods:{ async changeFavourites(id){ await fetch(`/api/menu/${id}`,{method:'PATCH'}) }, async increase(id){ await fetch(`/api/incr/${id}`,{method:'PATCH'}) }, async decrease(id){ await fetch(`/api/decr/${id}`,{method:'PATCH'}) } }, data(){ return{ foods:[], } }, async mounted(){ const res = await fetch('/api/menu') this.foods = await res.json() } } Vue.createApp(App).mount('#app')
about 4 years ago · Juan Pablo Isaza
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!