在Nuxt文件(在这里),它说,"你可以选择打破模块文件到单独的文件:state.js,actions.js,mutations.js和getters.js."
我似乎无法找到如何做到这一点的任何例子-大量的打破Vuex店在根级进入的state.js,actions.js,mutations.js和getters.js,和为单独的模块文件,而是打破了模块本身倒没什么.
所以目前我有:
??? assets
??? components
??? store
??? moduleOne.js
??? moduleTwo.js
??? etc...
Run Code Online (Sandbox Code Playgroud)
而我想拥有的是:
??? assets
??? components
??? store
??? moduleOne
??? state.js
??? getters.js
??? mutations.js
??? actions.js
??? moduleTwo
??? etc...
Run Code Online (Sandbox Code Playgroud)
试试这个,/store/moduleOne/state.js我有:
export const state = () => {
return {
test: 'test'
}
};
Run Code Online (Sandbox Code Playgroud)
在/store/moduleOne/getters.js我有:
export const getters = {
getTest (state) …Run Code Online (Sandbox Code Playgroud)