-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Labels
need reproReproduction code is requiredReproduction code is required
Description
I'm traying to figure out how to work with namespaced modules in vuex. But I always get the error "unknown mutation type: products/openDialog" when I try to do a commit in my vuejs instance "this.$store.commit('products/openDialog');" and when I try to call a getter inside my computed property I get undefined "this.$store.getters['products/getDialogOpen']"
store/index.js
import Vuex from 'vuex'
import products from './modules/products';
import manufacturers from './modules/manufacturers';
const store = new Vuex.Store({
modules: {
products
},
strict: process.env.NODE_ENV !== 'production'
});
export default store;
store/modules/products.js
...
const state = {
items: [],
dialogOpen: false
};
const mutations = {
closeDialog() {
state.dialogOpen = false;
},
openDialog() {
state.dialogOpen = true;
}
};
...
const getters = {
getDialogOpen: state => {
return state.dialogOpen;
},
...
};
export default {
namespaced: true,
state,
mutations,
getters,
actions
}
Vue Instance
...
computed: {
showDialog: {
return this.$store.getters['products/getDialogOpen'];
}
},
....
methods: {
onClose() {
this.$store.commit('products/closeDialog');
}
}
Metadata
Metadata
Assignees
Labels
need reproReproduction code is requiredReproduction code is required