vuex.esm.js?e4c8:1134 [vuex] module namespace not found in mapMutations():

 第一个问题解决办法:

vuex.esm.js?e4c8:985 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'commit')

报错原因:虽然使用了vuex但是store没有在main.js中注册使用

解决:在main.js中加入下面高亮的代码

import Vue from 'vue'

import App from './App.vue'

import VueRouter from 'vue-router'

import router from './router'

import element from 'element-ui'

import 'element-ui/lib/theme-chalk/index.css';

import './assets/reset.css'

import store from './store'

//导入语言

import i18n from './language/index'

import api from './api/index'

Vue.prototype.$api=api;

Vue.config.productionTip = false

Vue.use(VueRouter)

Vue.use(element)

new Vue({

  store,

  router,

  i18n,

  render: h => h(App),

}).$mount('#app')

 第二个问题解决方法:

 解决上面的之后有报:

 vuex.esm.js?e4c8:1134 [vuex] module namespace not found in mapMutations(): loginModule/

 介绍常规解决办法:

  • 检查小仓库中是否使用了命名空间  namespaced:true,    如果没有使用加入就好了,此时我的小仓库是叫loginModule。

 

  •  检查关键字是否拼写错误
  • 好了,到了我的问题了,真给我看吐了,搞了半天才解决。

解决示例如下:

 分析上图:你引人模块时起了一个别名叫lo,那么你在modules中注册的名字就应该是你的小仓库的名字:别名。

如果你的名字不符合标准也是会报这个错误的,而且我看这个错误也很少见

所以为了简单起见导入文件时最好就和小仓库名字一样,就可以简写啦

import Vue from 'vue'
import Vuex from 'vuex'
import loginModule from './modules/loginModule'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
  },
  mutations: {
  },
  actions: {
  },
  modules: {
    loginModule
  }
})

第三个问题解决:

vuex.esm.js?e4c8:460 [vuex] unknown mutation type: CATEGORYLIST 

  •  常见的解决办法:把你的小仓库里面的命名空间注释掉,也就是namespaced:true 注释掉
  • 不常见的,也就是我的问题,是因为小仓库里面的mutation没有加s。。。。啊啊啊啊真痛苦,搞了好久没找出来错误,原来小仓库里面的mutation也要加s,正确的写法是所有的仓库里面都是actions、mutations。所以你们好好检查一下看看
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
引用\[1\]:Uncaught TypeError: Object(...) is not a function at resetStoreState (vuex.esm-browser.js?5502:140:1) at new Store (vuex.esm-browser.js?5502:932:1) at eval (index.js?4360:48:1) at Module../src/store/index.js (index.js:1115:1) at __webpack_require__ (index.js:849:30) at fn (index.js:151:20) at eval (main.js:13:64) at Module../src/main.js (index.js:1103:1) at __webpack_require__ (index.js:849:30) at fn (index.js:151:20) vuex源码报错 google浏览器源代码。\[1\]这个错误是在Vuex源码中的resetStoreState函数中发生的,可能是因为在调用该函数时,传入的参数不是一个函数。具体的错误信息显示在浏览器的控制台中,可以通过查看源代码来定位问题所在。 引用\[2\]:TypeError: sub is not a function at eval (vuex.esm.js?2f62:422:1) at Array.forEach (<anonymous>) at Store.dispatch (vuex.esm.js?2f62:422:1) at Store.boundDispatch \[as dispatch\] (vuex.esm.js?2f62:332:1) at eval (list.vue?51fc:432:1) 这个错误是在调用Store.dispatch函数时发生的,可能是因为传入的参数sub不是一个函数。具体的错误信息显示在浏览器的控制台中,可以通过查看源代码来定位问题所在。 引用\[3\]:TypeError: sub is not a function at vuex.esm.js:422:1 at Array.forEach (<anonymous>) at Store.dispatch (vuex.esm.js:422:1) at Store.boundDispatch \[as dispatch\] (vuex.esm.js:332:1) at permissionsControl (permission.js:56:1) at permission.js:131:1 at iterator (vue-router.esm.js:1943:1) at step (vue-router.esm.js:1717:1) at step (vue-router.esm.js:1721:1) at runQueue (vue-router.esm.js:1725:1) 这个错误也是在调用Store.dispatch函数时发生的,同样是因为传入的参数sub不是一个函数。具体的错误信息显示在浏览器的控制台中,可以通过查看源代码来定位问题所在。 问题:Uncaught (in promise) TypeError: sub is not a function at eval (vuex.esm.js?2f62:422:1) 回答: 这个错误是在Promise中发生的,可能是因为在Promise的回调函数中调用了一个名为sub的函数,但是该函数并不存在或者不是一个函数。具体的错误信息显示在浏览器的控制台中,可以通过查看源代码来定位问题所在。 #### 引用[.reference_title] - *1* [Uncaught TypeError: Object(...) is not a function at resetStoreState (vuex.esm-browser.js?5502:1](https://blog.csdn.net/qq_41664159/article/details/123033963)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [vue2.x项目报错 vuex.esm.js sub is not function](https://blog.csdn.net/weixin_44786530/article/details/127316151)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [解决vue引发的报错-sub is not a function at vuex.esm.js:422:1跳转不了路由的问题](https://blog.csdn.net/imqdcn/article/details/126297459)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

H-rosy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值