I get the following error.
[Vue warn]: The property or method "updateData" is not defined in the instance, but is specified during rendering. Be sure to declare the properties of the reactive data in the data parameter.
As far as I can tell by code, the method exists, so I'm stuck on something that I am missing due to my ignorance of Vuex. I was looking for this question and got a lot of answers, but none of them made me wiser what to do. I feel that this is something of a sphere.
I also get the error below, but I suspect that this is the same root cause for both, so solving one will allow the other.
[Vue warn]: Invalid click event handler: received undefined (found in component in ...)
The markup is as follows. I checked that the path goes to the right place. At the moment, I'm not at all sure how to even start troubleshooting. Any clues would be appreciated.
<template> <div id="nav-bar"> <ul> <li @click="updateData">Update</li> <li @click="resetData">Reset</li> </ul> </div> </template> <script> import { updateData, resetData } from "../vuex_app/actions"; export default { vuex: { getters: { activeDataRow: state => state.activeDataRow }, actions: { updateData, resetData } } } </script>
Edit
After input, I improved the export to include a method property like this. (However, the same error remains).
export default { vuex: { getters: { activeDataRow: state => state.activeDataRow }, actions: { updateData, resetData }, methods:{ updateData: () => this.$store.dispatch("updateData"), resetData: () => this.$store.dispatch("resetData") } } }
Do I need to do something extra in the store? It looks like this.
import Vue from "vue"; import Vuex from "vuex"; Vue.use(Vuex); const state = { dataRows: [], activeDataRow: {} }; const mutations = { UPDATE_DATA(state, data) { state.dataRows = data; state.activeDataRow = {}; }, RESET_DATA(state) { state.dataRows = []; state.activeDataRow = {}; } }; export default new Vuex.Store({ state, mutations });