TypeError: Cannot read properties of undefined (reading ‘dispatch’)

在这里插入图片描述
在开发项目中遇到这个bug,记录一下解决办法

  1. 在入口文件main.js看注册的store有无大小写错误
import store from './store';
new Vue({
  router,
  store,
  render: h => h(App),
  //注册仓库,组件实例的身上会多一个$store属性
}).$mount('#app')
  1. 版本太高
    vue2安装3版本的vuex,默认安装的4版本给vue3用
//卸载原来安装的vuex
npm uninstall vuex
//安装3.6.2版本的vuex
npm install vuex

nprogress
在这里插入图片描述
在查看完代码无错误后去翻了一下nprogress的使用教程
发现进度条关闭的方法居然是done()不是end()!!!


nProgress.end();//错误
nProgress.done();//正确

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐