No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Error in event handler for "input": "TypeError: this.$store.commit is not a function"

    Framework
    2
    2
    710
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      safallah last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman last edited by

        this.$store prototype only works on a vue file. in your code use your imported reference name accordingly since it’s a js file.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post