Vue.js store prompts Cannot read property 'commit' of undefined

store, has been introduced but I don"t know why I still prompt undefined, to solve it! Thank you
import Vue from "vue"
import iView from" iview"
import "iview/dist/styles/iview.css"
import Router from".. / router"
import store from". / store/quanxianStore"

import App from".. /.. / vue/admin/quanxian.vue"

Vue.use (iView)

new Vue ({

el: "-sharpapp",
router: Router,
store: store,
render: h => h(App)

})
/ * *

  • Extends interfaces in Vue.js

* /

vue.d.ts
import Vue, {ComponentOptions} from "vue";
import {Store} from ". / index";

declare module "vue/types/options" {
interface ComponentOptions < V extends Vue > {

store?: Store<any>;
quanxianStore?: Store<any>;

}
}

declare module "vue/types/vue" {
interface Vue {

$store: Store<any>;
$quanxianStore: Store<any>;

}
}

clipboard.png

Mar.25,2022

possible reasons:

  1. failed to quote vux, correctly when using store.commit, resulting in an error;
  2. you may use it this way, when you deconstruct the assignment, you open it in the wrong way, resulting in an error.

clipboard.png

in short, you should check the code that an object with a value of undefined reports an error when referencing the commit property.


you have solved it yourself!

Menu