我有以下情况:
组件文本字段:
<v-text-field
v-model="form.profile.mobile_business"
label="Mobile"
prepend-inner-icon="mdi-cellphone"
></v-text-field>
我通过以下方式获取当前值:
data() {
return {
form: {
profile: JSON.parse(JSON.stringify(this.$store.getters["user/Profile"])),},};
},
我有一个调用此方法的提交按钮:
updateUserProfile() {
this.$store.dispatch("user/updateProfile",this.form.profile);
}
一切正常。在我的商店调度中,我进行API调用并通过我的突变来更新商店:
context.commit('UPDATE_PROFILE',profile);
在执行此步骤之前没有错误。
但是,如果我再次更改表单输入-在按下提交按钮后,我得到:
vuex:请勿在突变之外变异vuex存储状态
但是我不想仅在更改表单输入中的值时更改vuex存储。 仅当有人点击“提交”按钮时,它才应该更新。