Cart Items for an onlineshop to display the quantity instead of X times the same item. this.$store.state.cartItems holds all cart items as an array.
my computed property looks like this:
computed: {
cartItems() {
const ci = []
this.$store.state.cartItems.map((item) => {
const index = ci.indexOf(item)
if (index !== -1) {
ci[index].quantity += 1
} else {
ci.push(item)
}
})
return ci
},
},
but for some reason index is always -1, what do I do wrong here?
But why are you pushing
aaah, I now know what you're asking, I think
ci is empty
R.groupBy(getItemId)
Обсуждают сегодня