store/index.js should export a method which returns a Vuex instance.
采用的模块化写法就这样报错,现在换回普通模式就对了
框架是nuxt.js
不知道哪写错了,求大神,不是很懂ES6
这是代码结构
按照上图顺序,这分别是对应代码
export const getActiveIndex = state => {
return state.activeIndex || 1;
};
import mutations from '../../mutation/body/index.js';
import * as getters from '../../getter/body/index.js';
const body = {
state: mutations.state,
mutations: mutations.mutations,
getters: getters
}
export default body
import * as types from '../../mutation-types/body/index.js';
const state = {
activeIndex: 1,
};
const mutations = {
[types.SIDEMENU] (state,{activeIndex}) {
state.activeIndex = activeIndex
}
}
export default {
state,
mutations
};
export const SIDEMENU = 'SIDEMENU'
import Vue from 'vue';
import Vuex from 'vuex';
import body from './module/body/index.js';
Vue.use(Vuex);
const debug = process.env.NODE_ENV !== 'production';
export default new Vuex.Store({
modules: {
body,
},
strict: false
});
这是错误提示
Nuxt.js Error:
Error: [nuxt] store/index.js should export a method which returns a Vuex instance.
at getModule (.nuxt/store.js:53:10)
at Object.module.exports.Object.defineProperty.value (.nuxt/store.js:16:14)
at __webpack_require__ (webpack:/webpack/bootstrap c85da9788740a1862fce:25:0)
at Object.<anonymous> (server-bundle.js:1028:68)
at __webpack_require__ (webpack:/webpack/bootstrap c85da9788740a1862fce:25:0)
at Object.<anonymous> (server-bundle.js:1461:65)
at __webpack_require__ (webpack:/webpack/bootstrap c85da9788740a1862fce:25:0)
at server-bundle.js:95:18
at Object.<anonymous> (server-bundle.js:98:10)
at evaluateModule (D:\work\inner-eye\node_modules\vue-server-renderer\build.js:5820:21)
at D:\work\inner-eye\node_modules\vue-server-renderer\build.js:5878:18
at Promise (<anonymous>)
at D:\work\inner-eye\node_modules\vue-server-renderer\build.js:5870:14
at Nuxt.renderToString (D:\work\inner-eye\node_modules\vue-server-renderer\build.js:6022:9)
at P (D:\work\inner-eye\node_modules\pify\index.js:49:6)
at Promise (<anonymous>)
嗯。。。你返回个函数就好了。。。