Articles
Latest
More
Newsletter Sponsorship Discord About
Sign up for our Newsletter
The video for this lesson is currently being updated, please read the transcript instead.
Build Your First Vue.js App > Lesson 23

Implementing `inc` and `dec` logic

Let's now implement the logic of these two methods. Firstly, inc. We're passing in the item that the user wants to increment. So we can simply just go item.qty++.

Keep in mind we also need to increment the total value as well by the price of the item. We can do that by going this.total += item.price like that.

methods: {
  addItem: function(index) {...},
  inc: function(item) {
    item.qty++;
    this.total += item.price;
  },
  dec: function(item) {...}
}

Back to course page

Click to load comments...

Articles
  • Latest
Newsletter
  • Join
  • Sponsorship
More
  • Discord
  • Vue.js jobs
  • About

Vue.js Developers © 2021. View our privacy policy .

  • RSS
  • |
  • Atom