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.
14 lines
404 B
14 lines
404 B
// 接口 Point2D 和 Point3D 都具有 x、y 属性,重复两次,繁琐
|
|
/* interface Point2D { x: number; y: number }
|
|
interface Point3D { x: number; y: number; z: number } */
|
|
|
|
// 使用接口继承,实现复用
|
|
interface Point2D { x: number; y: number}
|
|
// Point3D 具有 Point2D 的 x、y 属性
|
|
interface Point3D extends Point2D { z: number}
|
|
|
|
let p3: Point3D = {
|
|
x: 20,
|
|
y: 30,
|
|
z: 40
|
|
}
|