sreed-web-programming/main.js

19 lines
295 B
JavaScript
Raw Normal View History

2021-12-13 20:15:05 +00:00
const app = Vue.createApp({
data() {
return {
cart: [],
}
},
methods: {
addToCart(item) {
this.cart.push(item)
},
removeFromCart(item) {
index = this.cart.indexOf(item)
if (index > -1) {
this.cart.splice(index, 1)
}
},
},
})