[Vuejs]-How to add items to array without creating duplicates in cart in vue 3?

0👍

You need to change this line this.cart.findIndex((x) => x === item) to this.cart.findIndex((x) => x.id === item.id). Assuming that ID is unique.

Leave a comment