I'm having trouble understanding how to pass actions with payloads using Vuex. I know i need a mutation to change the state, and that its best practice to use an action to dispatch the mutation. Not sure how I call the action and pass in a parameter though. Whenever I try this I get the error:
"Uncaught TypeError: Cannot read property 'isComplete' of undefined"
// Store.js
const mutations = {
completeTodo: function (state, todo) {
console.log(todo)
todo.isComplete = todo.isComplete || false
state.toggleAll = false
}
}
const actions = {
completeTodo: ({commit}) => commit('completeTodo')
}
//Todo.vue
methods: {
...mapActions([
'completeTodo'
])
}
<input type="checkbox" name="isCompleted" " v-on:change="completeTodo(todo)" class="todoCheck" />