注意:1.左边读取的字段,右手边必须有
2.读取的是右边的一个层级

4-1 数组的解构

  1. var obj = {
  2. name:"lisi",age:18,skill:"vue",
  3. s:{
  4. sex:"male"
  5. }
  6. }
  7. /*
  8. var name = obj.name
  9. var age = obj.age
  10. var skill = obj.skill
  11. */
  12. var {name,s} = obj
  13. console.log(name);
  14. console.log(s.sex);

4-2 对象的解构

  1. let {a,b}={a:12,b:24};
  2. console.log(a);
  3. console.log(b);