Answer the question
In order to leave comments, you need to log in
When I add a new contact, I get an error [vuex] unknown action type: ADD_CONTACT?
here is my method:
addContact(payload) {
this.$store.dispatch({type:'ADD_CONTACT'}, payload)
}
mutations:{
ADD_CONTACT:(state,payload)=> {
state.contacts.push(payload)
}
},
actions:{
addContact:(context,payload)=> {
context.commit({type:'ADD_CONTACT'}, payload)
}
},
Answer the question
In order to leave comments, you need to log in
this.$store.dispatch({type:'ADD_CONTACT'}, payload)
actions:{
addContact:
this.$store.dispatch({
type: 'addContact',
payload,
});
actions: {
addContact: ({ commit }, { payload }) => commit('ADD_CONTACT', payload),
},
this.$store.commit('ADD_CONTACT', payload)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question