I have a vuex data type as new Map(). and I need to get updated data in 3 components. But when I update vuex state, I can't get the updated data in components, but I can check updated data in console... I think computed can't catch updated value. Please check below code and advise me.
template
<input type="text" v-model="input" @keypress.enter="save" />
<table>
<tr v-for="list in getList" :key="list.id">
<td>{{ list.id }}</td>
<td>{{ list.title }}</td>
</tr>
</table>
script
methods: {
save() {
let newItem = {
id: this.input,
};
let newItemAdded = this.$store.getters.list.set(newItem.id, newItem);
this.$store.commit("addNewItem", newItemAdded);
},
}
computed: {
getList() {
let a = [];
this.$store.getters.list.forEach((l) => {
a.push(l);
});
return a;
},
}
store
getters: {
list: state => {
return state.list
}
},
mutations: {
addNewItem(state, payload) {
state.payload = payload
}
}