Vue.js
[Vue.js] Categorizing lists
brightlightkim
2022. 5. 11. 08:39
//HTML
{{item.product.price | currency}}
methods: {
addItem: function(product) {
var whichProduct;
var existing = this.cart.filter(function(item, index) {
if (item.product.id == Number(product.id)) {
whichProduct = index;
return true;
} else {
return false;
}
});
if (existing.length) {
this.cart[whichProduct].qty++;
} else {
this.cart.push({product: product, qty: 1})
}
}
}