0👍
✅
You shouldn’t bind the state’s variable like you did here: v-model="profile.groupName"
(in pratice you are mutating a prop outside vuex mutation and you are probably getting some console warning about that).
So you can copy getProfile
value to a local variable (vue’s data()
) and dispatch an action to update profile
in state when you want (according to a handler or whatever).
0👍
It’s because Vue allows you to modify vuex state directly when not in strict mode. If you enable strict mode, any mutation outside a mutation handler will throw an error.
export default {
state,
getters,
actions,
mutations,
strict: true
}
The Vuex guide mentions it here. You could also enable it only for development
strict: process.env.NODE_ENV !== 'production'
Source:stackexchange.com