[Vue warn]: Error in render: "TypeError: Cannot read property 'getters' of undefined"

[Vue warn]: Error in render: "TypeError: Cannot read property 'getters' of undefined"

这是我的 app.js 我是否正确定义了项目? 我想我做对了!按照vuex文档

import store from "./store";
require('./bootstrap');
window.Vue = require('vue').default;
import vuetify from "./vuetify";
import router from "./router";
import AppComponent from "./components/AppComponent";
import Store from  "./store"
const app = new Vue({
  el: '#app',
  vuetify,
  router,
  Store,
  components:{
    "app-component":AppComponent,
  }
});

这是我的store.js

import Vue from 'vue'
import Vuex from  'vuex'
Vue.use(Vuex)

const departmentRoute= [
  { icon: 'mdi-account-badge-outline', text: 'مدیریت  مطالبات   ' ,link:'demands'},
  { icon: 'mdi-account-badge-outline', text: 'مدیریت  گزارشات   ' ,link:'reports'},
];
const SuperAdminRoute= [
  { icon: 'mdi-account-group-outline', text: '  مدیریت کاربران ' ,link:'users'},
  { icon: 'mdi-account-badge-outline', text: 'مدیریت  مطالبات   ' ,link:'demands'},
  { icon: 'mdi-account-badge-outline', text: 'مدیریت  گزارشات   ' ,link:'reports'},
  { icon: 'mdi-account-badge-outline', text: 'آمار و ارقام     ' ,link:'demands'},
];
const studentRoute= [
  { icon: 'mdi-account-group-outline', text: 'آخرین مطالبات به رای گذاشته شده' ,link:'selfDemand'},
  { icon: 'mdi-account-group-outline', text: 'مطالبات من  ' ,link:'selfDemand'},
  { icon: 'mdi-account-badge-outline', text: ' پیگیری مطالبه   ' ,link:'addReport'},
  { icon: 'mdi-checkbox-marked-circle-outline', text: 'تایید حساب کاربری' ,link:'verify'},
];
export default new Vuex.Store({
  state: {
    level: localStorage.getItem('role')
  },
  getters: {
    items: state => {
      switch (state.level) {
        case "super-admin":
          return SuperAdminRoute;
        case "department":
          return departmentRoute;
        default:
          return studentRoute;
      }
    }
  }
})

这是我的应用程序组件脚本:

<script>
import { mapGetters } from 'vuex'

export default {
  name: "MainDashboard",
  props: {
      source: String,
  },
  computed: {
    ...mapGetters(['items'])
  },
  data: () => ({
    drawer: null,
    title:'فاد | فارغ التحصیلی ناد',
  }),
  methods:{
    logout() {
      axios.post('/api/logout').then(res=>{
        localStorage.removeItem('token');
        localStorage.removeItem('role');
        this.$router.push('/login');
      }).catch(err=>{
      });
    }
  }
}
</script>

当我在我的组件中使用 map getter 时,我可以在 vuex 选项卡中获取我的 getter,但我无法在组件计算中获取它 属性! 为什么 ? 我该如何排除故障?这个错误可能是由于无效的 import vuex 造成的吗?

Vuex 选项卡:

分量:

您必须像这样在 app.js 或 main.js 中使用商店:

import Vue from "vue";
import App from "./App.vue";
import store from "./store";

Vue.config.productionTip = false;

new Vue({
  render: (h) => h(App),
  store
}).$mount("#app");

如果你像 import {store} from "./store"; 这样使用,你会得到这个错误。

我从

更改了这一行
import Store from  "./store"

至:

import store from  "./store"

我的问题解决了!