0๐
I face this in my past project and I create 1 function to init state to reduce code repetition:
function initDialogState: () => ({
isValid: true,
isVisible: false,
errorMsg: '',
})
state: {
items: [
],
dialog: {
login: initDialogState(),
signup: initDialogState(),
}
}
then your mutation can be (I will create an example in Vuex structure):
setDialog(state, { kind, type, value }) {
Vue.set(state[kind], type, value)
}
๐คQuoc-Anh Nguyen
- [Vuejs]-Vue.js 3- Component doesn't load in VueJS with router
- [Vuejs]-Nesting component in a component
Source:stackexchange.com