Answer the question
In order to leave comments, you need to log in
How to trigger vuex store mutation from component if vuex is split into modules?
I don’t understand how to cause a mutation from a component:
vuex itself
export default new Vuex.Store({
modules: {
residentials,
administration
}
})
import { HTTP, Routes } from '@/components/Server/API'
export default{
// namespaced: true,
state:{
usersInGroup: {},
groups: [],
roles: [],
users: 3
},
actions:{
},
mutations:{
getUsersinGroup(state) {
console.log('data');
HTTP.post(Routes.getUsersinGroup, {})
.then(({ data }) => {
state.usersInGroup = data;
state.groups = data.groups;
state.roles = data.roles;
state.users = data.users;
console.log(data);
})
.catch(error => {
console.error(error);
});
}
}
}
mounted() {
console.log(this.$store.state.administration.users); // это для теста( работает)
this.$store.commit.administration('getUsersinGroup') // тут не работает, как правильно вызвать
}
Answer the question
In order to leave comments, you need to log in
If namespaces are not specified - this.$store.commit('getUsersinGroup');
https://vuex.vuejs.org/en/guide/modules.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question