5.接口.ts 463 B

12345678910111213141516171819
  1. (function() {
  2. // 接口 定义数据类型的规范
  3. interface vase {
  4. name: string,
  5. age1: number
  6. }
  7. class Person2 implements vase {
  8. name:string;
  9. age1: number;
  10. color: string;
  11. constructor(name:string,age:number,color:string) {
  12. this.name = name;
  13. this.age1 = age;
  14. this.color = color;
  15. }
  16. }
  17. let p3 = new Person2('图图',3,'红');
  18. console.log(p3);
  19. })()