我觉得可能是你构建store和引入的方式有问题,一般来说我会新建一个store.js来构建vuex的store,大概像这样。 import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) // 在这里引入 // 在这里导出实例 export default const store = new Vuex.Store({ state: {}, getters: {}, mutations: {}, actions: {} }) 然后在main.js中加入store,像这样 import Vue from 'vue' import store from 'store' new Vue({ // ...其他配置内容 store }) 附带一下Vuex官网,上面介绍比我详细,比较基础。
我觉得可能是你构建store和引入的方式有问题,一般来说我会新建一个store.js来构建vuex的store,大概像这样。
然后在main.js中加入store,像这样
附带一下Vuex官网,上面介绍比我详细,比较基础。