Vuejs 2, VUEX, data-binding when editing data

前端 未结 4 1199
情书的邮戳
情书的邮戳 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 14:03

    @AfikDeri solution is great, but it only create a shallow copy(for example it wont work if you have nested objects, which is common to have), to solve this you may serialize then parse your vuex state object getUserDetails, as follow:

    created (){
        this.profile = JSON.parse(JSON.stringify(this.$store.getters.getUserDetails));
    }
    

提交回复
热议问题