解构允许我们引用一个对象中的一个键,但是将其声明为具有不同名称的变量。该语法看起来像普通JavaScript对象的键值语法。
let user = {
name: 'John Smith',
id: 10,
email: 'johns@workcorp.com',
};
let {user: userName, id: userId} = user;
console.log(userName) // 约翰·史密斯
console.log(userId) // 10