注意:1.左边读取的字段,右手边必须有
2.读取的是右边的一个层级
4-1 数组的解构
var obj = {
name:"lisi",age:18,skill:"vue",
s:{
sex:"male"
}
}
/*
var name = obj.name
var age = obj.age
var skill = obj.skill
*/
var {name,s} = obj
console.log(name);
console.log(s.sex);
4-2 对象的解构
let {a,b}={a:12,b:24};
console.log(a);
console.log(b);