博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
typeScript面试必备之-通识八:typeScript中的接口的继承、接口的扩展
阅读量:6966 次
发布时间:2019-06-27

本文共 2011 字,大约阅读时间需要 6 分钟。

接口扩展:接口可以继承接口

interface Animal{  eat():void;}interface Person extends Animal{//接口的继承  work():void;}class Programmer{  public name:string;  public age?:number;//可选参数  constructor(name:string,age?:number){//age是可选参数      this.name=name;      this.age=age;  }  coding(code:string){      console.log(this.name+code)  }}class Web extends Programmer implements Person{ //web继承program复制代码

实现Person接口

constructor(name:string){     super(name)  }  eat(){//必须实现Person继承Animal的eat方法      console.log(this.name+'喜欢吃馒头')  }  work(){//必须实现Person的eat方法      console.log(this.name+'写代码');  }}var w=new Web('小李');w.eat();w.coding('写ts代码');复制代码
感谢: 参考学习:https://www.itying.com:
自己总结到有道云笔记里面有更加清楚的标注方便查阅:
* Typescript 介绍
http://note.youdao.com/noteshare?id=c3e0d5810580041ade028a345519ce96&sub=E882CE350AC94C5596B146908C406274 * typeScript中的数据类型
http://note.youdao.com/noteshare?id=a07dd9a55779068d9409b79014a9a409&sub=CE3DA74B1A27412792DF9BB8F74E8E24 * typeScript中的函数
http://note.youdao.com/noteshare?id=adc64e95404f3c382c7549f05841c7b2&sub=65D365DE900049A28DD4697B61A5544A * 对象+继承
http://note.youdao.com/noteshare?id=7f82be21375761c13ccad1981510a614&sub=7856743A59934A59A1AA608AA78497F0 * 类的定义、继承、类里面的修饰符 http://note.youdao.com/noteshare?id=a4420ac729d8cc7c1eb72fc47198f00b&sub=399974DBD9FA4EC2A99548D8837CB61F * 静态属性 静态方法 抽象类多态
http://note.youdao.com/noteshare?id=efad91320514e4f21e07ec77a9bcfd7c&sub=DC3868B8459940CA884DC5B80EE25443
* typeScript中的接口
http://note.youdao.com/noteshare?id=ae4c7f13bec8e35b3fda4e326d7e7055&sub=6001FADE75904080A15395886608D366 * 可索引接口(数组,对象)+类类型接口
http://note.youdao.com/noteshare?id=aebf26ab922044a69cae082866ce8d86&sub=F73FB04DD10C4BA796173FBE40280B21
* 接口的继承、接口的扩展
http://note.youdao.com/noteshare?id=93e1dff481b8e299ee9c925e8e3a8b4a&sub=3C96456BFAA34C28BA6BB4E0B0C1E77B * 泛类
http://note.youdao.com/noteshare?id=6d9e0ec4cdb17249bf1bb11fae2e44ec&sub=B0C47B2089AC42E48C2E1BAAAD3FE9EF * 泛型接口
http://note.youdao.com/noteshare?id=49af2ba1bd6173467e7c7b844def959b&sub=F16F0C2857E347C0B8FB69522D5DEFA2

转载地址:http://bsdsl.baihongyu.com/

你可能感兴趣的文章
find 命令详解
查看>>
世纪之战
查看>>
NOT NULL列用IS NULL也能查到数据?
查看>>
利用单臂路由实现VLAN间路由
查看>>
How to use tcpdump with examples
查看>>
windows下安装android版reactnative
查看>>
02.Apollo配置中心整合spring cloud zuul
查看>>
linux--nfs 网络文件共享
查看>>
MySQL索引的学习和研究
查看>>
Docker部署文档
查看>>
AngularJS实现产品列表(页面搜索,排序)
查看>>
面向对象的最后一课
查看>>
win7 64位系统连接xp 32位共享打印机办法
查看>>
cPanel之EasyApache (Apache Update)的使用
查看>>
在ESXi5,1,ESXi5.5安装异步驱动程序
查看>>
redis教程(一)之redis简介
查看>>
Direct2D (23) : 复合几何对象之 ID2D1GeometryGroup
查看>>
《Linux系统初讲》学习总结(一)
查看>>
普通(实例)方法和实例方法的定义和调用
查看>>
在 Delphi 下使用 DirectSound (12): 测试失真效果器 IDirectSoundFXDistortion8
查看>>