Vuejs 2, VUEX, data-binding when editing data

前端 未结 4 1197
情书的邮戳
情书的邮戳 2020-12-29 13:26

I have a user profile section and Im trying to allow the user to edit their information. I am using vuex to store the user profile data and pulling it into the form. The e

4条回答
  •  失恋的感觉
    2020-12-29 13:57

    The problem is caused by using v-model with mapGetters - this creates the two-way binding you've described. The simple solution is to use value instead:

    :value="profile.firstName"
    

    This way the form is only changing the local copy of field and not pushing the changes back to the Vuex store.

提交回复
热议问题