0

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...

1

2 Answers 2

1

You may use the spread operator like this,

this.initState.data = {...contacts[this.contanctID]}

Spread Operator MDN

1
  • No it doesnt work(, but method JSON stringlify -> JsonParse worked well
    – Padavan
    Commented Sep 8, 2020 at 9:43
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.