vuex两个问题:vuex__WEBPACK_IMPORTED_MODULE_1__.default.store is not a constructor,“$store“ is not defin

本文介绍了在Vue应用中遇到的两个Vuex常见错误:1) `vuex__WEBPACK_IMPORTED_MODULE_1__.default.store is not a constructor`,解决方法是确保在new Vuex时将'store'改为'Store';2) `Property or method $store is not defined on the instance`,此问题可能由于Vuex版本与Vue不匹配导致,解决办法是重新安装对应版本的Vuex,如vue2对应vuex3。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 vuex__WEBPACK_IMPORTED_MODULE_1__.default.store is not a constructor

第一个错误是很多人遇到过的,细节问题,在main.js里new Vuex的时候,store要大写S

//错误写法
const store =new Vuex.store({

})

//正确写法
const store =new Vuex.Store({

})

第二个错误:

Property or method "$store" is not defined on the instance but referenced during render. 

我是vue2,那么应该对应下载vuex3的版本,vue3对应vuex4,所以重新安装一下vuex就解决问题了:

npm i vuex@3 --S

或 

yarn add vuex@3 --S

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值