Search code examples
vue.jsvuex

Unlink state form store


I've had a problem

  data() {
    return {
      list: [],
      initState: { id: null, data: null }
    }
  },
  computed: {    
     ...mapState({
        contacts: (state) => state.ContactBook.Contacts
      })
     },},
      methods: {
        setinitState(payload) {
          this.initState.data = contacts[this.contactID]
        },

How Can I make this.initState static? I need this.initState didnt changes when contacts[this.contactID] changes...


Solution

  • state.snapshot = JSON.parse(JSON.stringify(state.Contacts[payload]))