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
}
浙公网安备 33010602011771号