不對?組件中data () { return {
item1: '',
item2: '',
item3: '',
item4: ''
}
},mounted () { if (this.privacy) {
let { this.item1, this.item2, this.item3, this.item4 } = { ...this.privacy }
}
}state里面的數(shù)據(jù)privacy: {
item1: 1,
item2: 1,
item3: 1,
item4: 1}
1 回答

30秒到達(dá)戰(zhàn)場
TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個(gè)贊
1 . 左邊與右邊要有映射關(guān)系 你這 左邊 this.item
跟右邊怎么 映射
2 . 一般情況解構(gòu)的左邊要有聲明 var let const
,大括號開頭會被解析成代碼塊 {xxx}
不是一個(gè)完整的表達(dá)式,要用 ()
包起來
const o = {}; ({name: o.n} = {name:'123'});console.log(o); // {n:'123'}
添加回答
舉報(bào)
0/150
提交
取消