0👍
Try the following, in the child component pass the id as follows:
this.$emit('remove', this.item.id);
Then, the parent renders the child as follows:
<ListItem v-for="item in listItems" :key="item.id"
:item="item"
@remove="deleteListItem"
/>
methods: {
...mapActions('listItems', ['deleteItem',],),
deleteListItem (id) {
this.deleteItem(id);
},
- [Vuejs]-How to add Old data to select inputs (looping by vue.js) in form
- [Vuejs]-Need help using Vue methods in routed templates
0👍
It turns out I needed to wrap the argument in an object when I pass it to the store. Doing this.deleteItem({id});
seemed to fix the issue…
- [Vuejs]-Integrate vue-i18n in vue-beautiful-chat
- [Vuejs]-V-binded image from local machine wont show, but from web does
0👍
the first argument in vuex actions is the context object. If you don’t want to use it and just use the payload you could use it like this:
deleteItem (_, id) {
api.del(`${deleteURL}/${id}`);
},
Source:stackexchange.com