I am facing a challenge with updating objects containing different strings using a single mutation and action in my project. Currently, I am attempting to extract a string from an input field's value and name, using the name as the object property to dynamically alter the state. However, I am struggling to determine how to access the correct object property based on the input name string.
Below is the code snippet I am working with:
store.js
info: {
fullName: '',
}
...
mutations: {
updateStateObject(state, object){
state.info.object["name"]
}
actions: {
updateStateObject(store, object){
store.commit('updateStateObject', object);
}
info.vue
updateStateObject(e){
this.$store.dispatch(this.store+'/updateStateObject', {name: e.target.name, value: e.target.value)}
Manually setting
state.info.["inputFieldName"] = object.value
works well, but I aim to invoke the updateStateObject method from the vue file using all input fields and accessing the correct property field in the state object based on the input field name. How can I achieve this successfully?