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.
Vue Foundations > Lesson 12

Creating the shopping cart

We've rendered some basic products now and given them an add to cart button.

Let's now make it so that when a user clicks the button the products show up in the shopping cart list.

Cart array

Back in our Vue instance, let's add a new data property called cart. It'll just be assigned an empty array, as obviously the cart will need to be empty when the app first loads.

public/script.js

data() {
  return {
    ...
    cart: []
  }
},

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