Courses
Vue Foundations Vue Fullstack Vue Enterprise
Articles
Latest Topics
More
Newsletter Sponsorship Discord About
The video for this lesson is currently being updated, please read the transcript instead.
Build Your First Vue.js App > 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...

Courses
  • Vue Foundations
  • Vue Fullstack
  • Vue Enterprise
Articles
  • Latest
  • Topics
Newsletter
  • Join
  • Sponsorship
More
  • Discord
  • Vue.js jobs
  • About

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

  • RSS
  • |
  • Atom