Hi, thank you for the post.
I have a question if you can help me.
I have the following folder structure in my project
project | -store | |-constants.js |-modules | |-someModule |-otherModule |-index.js (just as in your post)
This is a sample from my constants file
//Actions export const USER_SET = 'user/SET' export const USER_GET_ROLES = 'user/GET_ROLES' //Mutations export const USER_SET_BY_KEY = 'user/SET_BY_KEY' export const USER_SET_ROLES = 'user/SET_ROLES'
And in my modules I use the constant as name for the actions, mutations, getters, like in this sample
const actions = { [constants.USER_SET]: ({commit}, user) => { let response = {'data': user, 'key': 'user' } commit(constants.USER_SET_BY_KEY, response) }, }
The idea is that when I use in components, i use the constants file name too, this way I can change the name in one place
Like in this
...mapActions({ getRoles: constants.USER_GET_ROLES,
The thing is, even when the module are dinamically loaded by the index in the modules folder, Vuex doesn't recognize the actions, mutations, getters
I print the modules object in the index and i see that it has this properties empty
{ "customer": { "state": { "customers": null, "contacts": null }, "actions": {}, "mutations": {}, "getters": {} }, . . . .
}
If I go back to import every module manually and put then in the vuex individually, then vuex recognize the actions, mutations, getters
So thank you in advance if can you please point me in the right direction
p.s Sorry for my bad english, it's not my native language
Nevermind, It was a problem with the way I was telling vuex to use modules but thank you anyway
Glad you figured it out !
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi, thank you for the post.
I have a question if you can help me.
I have the following folder structure in my project
project
|
-store
|
|-constants.js
|-modules
|
|-someModule
|-otherModule
|-index.js (just as in your post)
This is a sample from my constants file
//Actions
export const USER_SET = 'user/SET'
export const USER_GET_ROLES = 'user/GET_ROLES'
//Mutations
export const USER_SET_BY_KEY = 'user/SET_BY_KEY'
export const USER_SET_ROLES = 'user/SET_ROLES'
And in my modules I use the constant as name for the actions, mutations, getters, like in this sample
const actions =
{
[constants.USER_SET]: ({commit}, user) =>
{
let response = {'data': user, 'key': 'user' }
commit(constants.USER_SET_BY_KEY, response)
},
}
The idea is that when I use in components, i use the constants file name too, this way I can change the name in one place
Like in this
...mapActions({
getRoles: constants.USER_GET_ROLES,
The thing is, even when the module are dinamically loaded by the index in the modules folder, Vuex doesn't recognize the actions, mutations, getters
I print the modules object in the index and i see that it has this properties empty
{
"customer": {
"state": {
"customers": null,
"contacts": null
},
"actions": {},
"mutations": {},
"getters": {}
},
.
.
.
.
}
If I go back to import every module manually and put then in the vuex individually, then vuex recognize the actions, mutations, getters
So thank you in advance if can you please point me in the right direction
p.s Sorry for my bad english, it's not my native language
Nevermind, It was a problem with the way I was telling vuex to use modules but thank you anyway
Glad you figured it out !