Answer the question
In order to leave comments, you need to log in
How to calculate the sum of goods in vue.js?
Good afternoon, forum users, please help a newbie, I'm studying vue.js and the task was to calculate the sum of all goods, tell me how to implement this?
let cartBox = new Vue({
el: '.marget',
data: {
cart: [
{price: 1000, cnt: 2},
{price: 800, cnt: 3}
]
},
computed: {
cartTotal() {
return this.cart.reduce((price, cnt) => price += cnt, 0)
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question