TS入门教程二

接口的学习

- 定义对象、数组、函数、类

 

定义对象🌰

interface Color{

  color:string

}

 

定义数组 🌰

interface Swiper{

  [index:number]:string;

}

const s1:Swiper=['1','3'];

 

定义函数 🌰

interface Grade{

  (name:string,color:string):boolean;

}

 

const g1:Grade=function(name:string,color:string){

  return true;

}

 

- 接口可以互相继承 

举个🌰 

interface Shape{

  color:string

}

interface Square extends{

  width:number

}

posted @ 2021-02-24 16:02  囚龙棒主  阅读(105)  评论(0)    收藏  举报