Vue3 Vuex.Store() Uncaught Error: [vuex] must call Vue.use(Vuex) before creating a store instance.

报错:Uncaught TypeError: Cannot read property 'use' of undefined

网上查阅资料说不再需要在Store.js中使用Vue.use(Vuex)。

于是我就注销了,但是还报错这个报错的是_vuex.default.store 不是一个构造函数因为在我们用vuex的时候需要将用到的actions,mutations模块最终导出,在导出的时候new Vuex.Store中的Store小写了,这里的一定要大写,就相当于我们在使用构造函数(类)的时候首字母要大写

还还报错:Uncaught Error: [vuex] must call Vue.use(Vuex) before creating a store instance.

心态崩了。。。。。。。。最后通过 npm uninstall vuex     VueX(3.6),再下载VueX(4.0 alpha)就可以了,

  • 我们可以通过卸载VueX(3.6)来使它正常工作
  • npm uninstall vuex
    
  • 1
  • 并安装VueX(4.0 alpha)
  • npm i vuex@4.0.0-alpha.1
    

这一系列下列,找了很多别人的解决方案,我这里只是记录整理一下,到它日再有这个错误的时候可以回来看看


参考链接:https://blog.csdn.net/weixin_46351593/article/details/113803641

参考链接:https://blog.csdn.net/FHlang/article/details/115765919

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
As an AI language model, I don't have personal experience with Uniapp or Vuex.Store, but I can explain some basic concepts and features of these technologies. Uniapp is a framework for creating cross-platform mobile applications using Vue.js. It allows developers to write code once and deploy it to multiple platforms, including iOS, Android, and web browsers. Uniapp provides a set of built-in components and APIs for mobile development, and it supports popular UI frameworks such as Vant and Element. Vuex.Store is a state management library for Vue.js applications. It provides a centralized store for managing the state of an application, making it easier to share data between components and manage complex application flows. Vuex.Store uses a reactive system to automatically update components when the store's state changes, and it provides a set of helper functions for managing state mutations and actions. In Vue.js 3, the Vuex.Store has been updated to support the new Composition API, which provides a more flexible and powerful way to build components and manage state. The Composition API allows developers to use reactive data, computed properties, and lifecycle hooks in a more modular and composable way, making it easier to build complex applications with reusable code. Overall, Uniapp and Vuex.Store are powerful tools for building cross-platform mobile applications with complex state management requirements. With the new Composition API in Vue.js 3, developers have even more flexibility and power to build scalable and maintainable applications.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值