Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于vuex设置? #10

Closed
weboth opened this issue Jun 19, 2017 · 4 comments
Closed

关于vuex设置? #10

weboth opened this issue Jun 19, 2017 · 4 comments

Comments

@weboth
Copy link

weboth commented Jun 19, 2017

store/index.js
`export const state = {
a: 0
}

export const mutations = {
add (state) {
state.a++
}
}`

npm run dev 后提示:

Error: [nuxt] state should be a function in store/index.js
at getModule (.nuxt/store.js:56:10)
at Object.module.exports.Object.defineProperty.value (.nuxt/store.js:16:14)
at webpack_require (webpack:/webpack/bootstrap 5c18ee9214ff34ee6da8:25:0)
at Object. (server-bundle.js:969:68)
at webpack_require (webpack:/webpack/bootstrap 5c18ee9214ff34ee6da8:25:0)
at Object. (server-bundle.js:1348:65)
at webpack_require (webpack:/webpack/bootstrap 5c18ee9214ff34ee6da8:25:0)
at server-bundle.js:95:18
at Object. (server-bundle.js:98:10)
at evaluateModule (D:\ssr\ssr\node_modules._vue-server-renderer@2.3.4@vue-server-renderer\build.js:5820:21)
at D:\ssr\ssr\node_modules._vue-server-renderer@2.3.4@vue-server-renderer\build.js:5878:18
at Promise ()
at D:\ssr\ssr\node_modules._vue-server-renderer@2.3.4@vue-server-renderer\build.js:5870:14
at Nuxt.renderToString (D:\ssr\ssr\node_modules._vue-server-renderer@2.3.4@vue-server-renderer\build.js:6022:9)
at P (D:\ssr\ssr\node_modules._pify@3.0.0@pify\index.js:49:6)
at Promise ()

请问使用状态树的模块化方式,是否需要配置其他地方呢?
一直在网上找demo,只有你的使用了这个模块化方式,我自己测试也不ok!
求教!

@surmon-china
Copy link
Owner

这个礼拜内会更新,nuxt 和 vuex升级导致的

@weboth
Copy link
Author

weboth commented Jun 19, 2017

3KS
官方文档错误,状态树的模块化方式也是改成promise,需要一个返回值

export const state = () => ({ a: 0 })

name =()=> 用箭头函数搞定

感谢已解决!

@surmon-china
Copy link
Owner

最新版是需要返回一个func,而不是一个obj

@surmon-china
Copy link
Owner

你应该是是升到了A版本,建议暂时不要升级,等1.0出正式版再做重构,项目刚升级到0.10.7了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants