Deconstructing assignment reporting error

the this.privacy in the component uses the data obtained from state by mapState. The following is written as follows: Unexpected token where did I write this wrong?

component

data () {
    return {
      item1: "",
      item2: "",
      item3: "",
      item4: ""
    }
},
mounted () {
    if (this.privacy) {
      let { this.item1, this.item2, this.item3, this.item4 } = { ...this.privacy }
    }
  }

state data

privacy: {
    item1: 1,
    item2: 1,
    item3: 1,
    item4: 1
}

Jul.09,2022

{ this.item1, this.item2, this.item3, this.item4 } = { ...this.privacy }

what is this.item1 here? It's a number or a string or something.
the official said:

The
deconstructing assignment syntax is an Javascript expression, which allows values to be extracted from arrays or attributes into different variables from objects.

notice later, the variable .
this.item1 is obviously not a variable.


1. There should be a mapping between the left and the right. How do you map the left this.item to the right
2. In general, there should be a declaration var let const on the left side of the deconstruction. The beginning of the curly braces will be parsed into a code block {xxx} , which is not a complete expression. It should be wrapped

with () .
const o = {};

({name: o.n} = {name:'123'});

console.log(o); // {n:'123'}

...; // 
({ item1: this.item1, item2: this.item2, item3: this.item3, item4: this.item4 } = { ...this.privacy })

Object.assign is recommended. If you have to write this, this is it ({item1:this.item1} = this.privacy)

Menu