[Vuejs]-Vue save localStorage for each items in list

0👍

If you make the following changes, it should work.

  1. Your renaissance array doesn’t currently have a property called id, so I would change your key to id so that :key="item.id" works

  2. passed the id to your Item component i.e. :id="item.id"

  3. added a prop in your Item component i.e. id: Number

  4. changed your localStorage keys to "item-" + this.id + "-buy" and "item-" + this.id + "-sell"

Now each buy and sell will have a different localStorage key, different by its id.

I’d greatly recommend using Vuex, it will make things easier in the long run What is Vuex?.

Leave a comment