Глубокий наблюдатель, который я установил для этого компонента, не обновляет хранилище при изменении значения текстового поля.Я не могу найти способ правильно изменить пару ключ / значение объекта хранилища (профиль) (groupName: string )
Profile.vue Элемент :
<v-text-field v-model="profileData.groupName" label="Group Name"></v-text-field>
Profile.vue JS :
import { mapGetters, mapMutations } from "vuex";
export default {
name: "Profile",
created() {
this.profileData = JSON.parse(JSON.stringify(this.getProfile()));
console.log(this.profileData);
},
data() {
return {};
},
methods: {
...mapGetters(["getProfile"]),
...mapMutations(["setProfile"])
},
watch: {
profileData: {
handler(value) {
this.setProfile(value);
},
deep: true
}
}
};
build.js ( Модуль store.js ):
const state = {
profile: {
"groupName": "Happy group",
"groupNumber": "9999999999",
"groupContact": "Bob Ross"
}
};
const getters = {
getProfile: (state) => state.profile,
};
const actions = { };
const mutations = {
setProfile: (state, profile) => (state.profile = profile)
};
export default {
state,
getters,
actions,
mutations,
}
Я не уверен, почему состояние не обновляется.Кто-нибудь знает?
Спасибо, что прочитали