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

288
Views
Refreshing button text when it is clicked

I'm trying to make this app work :

enter image description here

I want to make button with number change its number when + or - is clicked but I don't know how. Here is code (I'm new to this so I'm sorry if the code seems terrible to you):

Button's html :

<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>

app.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!