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.

13 lines
404 B

2 years ago
  1. // 接口 Point2D 和 Point3D 都具有 x、y 属性,重复两次,繁琐
  2. /* interface Point2D { x: number; y: number }
  3. interface Point3D { x: number; y: number; z: number } */
  4. // 使用接口继承,实现复用
  5. interface Point2D { x: number; y: number}
  6. // Point3D 具有 Point2D 的 x、y 属性
  7. interface Point3D extends Point2D { z: number}
  8. let p3: Point3D = {
  9. x: 20,
  10. y: 30,
  11. z: 40
  12. }