Error in event handler for "input": "TypeError: this.$store.commit is not a function"
-
Hello,
I am using the latest version of Quasar Framwork.
The vuex object does not contain commit and dispatch methods.
Error in event handler for “input”: “TypeError: this.$store.commit is not a function”
Error in event handler for “input”: “TypeError: this.$store.dispatch is not a function”How can i resolv it ?
this is my code:store/module-example/mutations.js
export const updateDrawerState = (state, opened) => {
state.drawerState = opened;
};store/module-example/state.js
export default {
drawerState: true,
};store/module-example/index.js
import state from ‘./state’;
import * as getters from ‘./getters’;
import * as mutations from ‘./mutations’;
import * as actions from ‘./actions’;export default {
namespaced: true,
state,
getters,
mutations,
actions,
};component/demo/demo.script.js
import exampleStore from ‘…/…/store/module-example’;
export default {
name: ‘demo’,
store: exampleStore,
data() {
return {};
},
computed: {
drawerState: {
get() {
return this.$store.state.drawerState;
},
set(val) {
console.info('drawerState SET: ', this.$store);
this.$store.commit(‘example/updateDrawerState’, val);
},
},
},
};components/demo/demo.tml
<div>
<q-toggle v-model=“drawerState” />
</div>Thank you.
-
this.$store
prototype only works on a vue file. in your code use your imported reference name accordingly since it’s a js file.