代码如下import 'babel-polyfill'import Vue from 'vue'import VueRouter from 'vue-router'import store from './vuex/store'import http from 'vue-resource'import App from './App.vue'import Vuex from 'vuex'Vue.use(http)Vue.use(VueRouter)Vue.use(Vuex)Vue.http.options.root = '/root'Vue.http.options.emulateJSON = trueVue.config.debug = truevar router = new VueRouter()require('./routerConfig')(router)new Vue({ store: store, components: { App }})router.start(App, '#app')然后store文件import Vuex from 'vuex'import frontPage from './modules/frontPage'import viewsPage from './modules/viewsPage'import commentPage from './modules/commentPage'import Vue from 'vue'Vue.use(Vuex)export default new Vuex.Store({ modules: { frontPage, viewsPage, commentPage }})然而控制台的输出却是这样的![vuex] store not injected. make sure to provide the store option in your root component.不知道怎么解决,求助求助!
2 回答
幕布斯6054654
TA贡献1876条经验 获得超7个赞
拉丁的传说
TA贡献1789条经验 获得超8个赞
错误点太多了;router文件只要配置好router就ok了,store只要注册好各个模块的state,mutations就行了,需要注意的就是router里的app.vue文件,需要引入store
app.vue
<script> import store from './vuex/store.js'; export default{ store, data(){ }, components:{ } } </script>
添加回答
举报
0/150
提交
取消