vuex报错Cannot read properties of undefined (reading ‘dispatch‘)报错this.$store的值是undefined的原因

网上关于这个报错的原因各种各样的。解决办法也各不相同。

本次报错,问题描述:

登录时。调用 this.$store报错:

this.$store: undefined
vue.min.js:6 TypeError: Cannot read properties of undefined (reading 'dispatch')

 

 

问题分析:

因为在index.html里面已经全局引用了。

 

所以这里就不能再引用了:

 解决办法:

把store里的index.js里的引用去掉即可。不要重复引用


版权声明:本文为qq_22182989原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。