1π
β
I think the problem here, is Vue is not watching your localStorage so it has no idea when to update.
If you need to use your localStorage, you should let Vue know whether it has changed or not. Something like..
...
data() {
return {
yourList: []
}
}
...
methods: {
removeItem (clickedId) {
this.yourList = this.yourList.filter((item) => item.id !== clickedId);
localStorage.setItem("items_ids", JSON.stringify(this.yourList));
}
},
So in this code weβre not controlling data from localStroage. We control reactivity data which is yourList
and just keep updating localStorage manually
π€Ikhyeon Kim
Source:stackexchange.com