computed: {
cartTotalCost() {
let result = []
if (this.cart_data.length) {
for (let product of this.cart_data) {
result.push(product.price * product.amount)
}
result = result.reduce(function (sum, el) {
return sum + el;
})
return result
} else {
return 0;
}
},
data() {
return {
obj:{
...
}
}
}
computed: {
cartTotalCost() {
return this.cart_data.reduce((acc, n) => acc + n.price * n.amount, 0);
},
...