The video for this lesson is currently being updated, please read the transcript instead.

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: []
  }
},

To view the complete lesson you'll need to login or join this course.


Click to load comments...