vuex Cannot read properties of undefined (reading 'commit')"
时间: 2023-08-28 11:16:58 浏览: 421
回答: 这个错误是由于在Vue组件中调用Vuex的commit函数时发生的。具体报错信息是"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'commit')"。根据引用和引用的信息,这个错误是因为在函数内部通过this.$store取值时得到的结果是undefined,也就是找不到commit属性。这可能是由于未正确配置或初始化Vuex store引起的。要解决这个问题,你可以确保在Vue实例中正确引入Vuex并配置store对象,并且在组件中使用this.$store.commit函数时确保Vuex store已正确加载并且commit函数可用。<span class="em">1</span><span class="em">2</span>
#### 引用[.reference_title]
- *1* [成功解决:Cannot read properties of undefined (reading ‘commit‘)](https://blog.csdn.net/weixin_43304253/article/details/126871726)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [uniApp 使用Vuex 出现 Cannot read properties of undefined (reading ‘commit‘)情况](https://blog.csdn.net/m0_60721514/article/details/123080522)[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^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文