You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
314 B

2 years ago
  1. // 泛型工具类型:Pick<Type, Keys> 从 Type 中选择一组属性来构造新类型
  2. interface Props{
  3. id: string
  4. title: string
  5. children: number[]
  6. }
  7. // 从 Props 中选择两个属性给 PickProps
  8. type PickProps = Pick<Props, 'id' | 'title'> // PickProps 具有 Props 的 id 和 title 属性