Vue.js 使用vuex存储区时出现未知操作类型错误

Vue.js 使用vuex存储区时出现未知操作类型错误,vue.js,vuex,store,Vue.js,Vuex,Store,我试图分派一个操作,但我得到了这个错误:“未知操作类型” 我知道我为什么会犯这个错误,但我不知道我做错了什么 我的组成部分: created() { this.$store.dispatch('techValid/fetchTechValids'); }, 我的商店(index.js): My store(techValid.js是存储中的模块文件夹): Main.js: //Some imports new Vue({ el: '#app', store, rout

我试图分派一个操作,但我得到了这个错误:“未知操作类型”

我知道我为什么会犯这个错误,但我不知道我做错了什么

我的组成部分:

created() {
    this.$store.dispatch('techValid/fetchTechValids');
  },
我的商店(index.js):

My store(techValid.js是存储中的模块文件夹):

Main.js:

//Some imports

new Vue({
  el: '#app',
  store,
  router,
  components: { App },
  template: '<App/>',
});

//一些导入
新Vue({
el:“#应用程序”,
商店,
路由器,
组件:{App},
模板:“”,
});

您只需使用如下操作名称调用
操作

created() {
    this.$store.dispatch('fetchTechValids');
}
调用操作和变量时,不需要指定模块名

action
函数中,您可以调用
translations
like

actions: {
  async fetchTechValids({commit}) {
     let response = await axios.get('http://localhost:3080/techValid'); // since async function is using, you can directly get the response.
     console.log('API CALL OK');
     console.log(response);
     commit('SET_ALL_TECHVALIDS', response);
  },
}

您可以在调用
commit
之前使用if条件来捕获错误,也可以使用
try catch
来捕获错误。

谢谢大家

现在可以工作了,我删除了分派中的模块名:
this.$store.dispatch('fectTechValids')


并删除了我的存储中的名称空间,只需导出
状态、获取项、突变、操作

请共享存储代码我刚刚编辑了我的问题;)
created() {
    this.$store.dispatch('fetchTechValids');
}
actions: {
  async fetchTechValids({commit}) {
     let response = await axios.get('http://localhost:3080/techValid'); // since async function is using, you can directly get the response.
     console.log('API CALL OK');
     console.log(response);
     commit('SET_ALL_TECHVALIDS', response);
  },
}