Vue.js

[Vue.js] Adding computed classes

brightlightkim 2022. 5. 11. 08:45
//JS
computed: {
	cartTotal: function() {
    	let sum = 0;
        for (key in this.cart) {
        	sum = sum+this.cart[key].product.price * this.cart[key].qty);
        }
        return sum;
    },
    cartQty: function() {
    	let qty = 0;
        for (key in this.cart) {
        	qty = qty+this.cart[key].qty);
        }
        return qty;
    }
}

'Vue.js' 카테고리의 다른 글

[Vue.js] Components based Vue  (0) 2022.05.12
[Vue.js] Deleting Items and Modifiers  (0) 2022.05.11
[Vue.js] Categorizing lists  (0) 2022.05.11
[Vue.js] Toggling elements with a key  (0) 2022.05.11
[Vue.js] filters  (0) 2022.05.11