
typescript
文章平均质量分 57
碵蝎
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
01.基本数据类型
/*typescript中的数据类型 : boolean number string array tuple enum any null 和 undefined void never 其中,tuple、enum、any、never为typescript中新增加的 ------------------------------------------- 定义变量 在js中,定义变量的方法如下 :...原创 2018-08-10 21:55:32 · 280 阅读 · 0 评论 -
02.函数
/* 函数定义 在typescript中,函数需要写上函数返回值的类型。如 : function say():void{ console.log('hello') } function getName():string{ return 'tom'; } ----------------------------------------- 函数传参 function ge...原创 2018-08-10 22:39:29 · 250 阅读 · 0 评论 -
03.类
/* * 在ts中定义一个类使用class关键字。如 : class Person { name:string; age : number; constructor(name:string, age:number){ this.name = name; this.age = age; } getName():string...原创 2018-08-10 23:28:51 · 235 阅读 · 0 评论 -
04.静态属性和静态方法
/* 静态属性和静态方法 使用static关键字来修饰 * */ class Boy{ name:string; static sex = '男'; constructor(name:string){ this.name = name; } static showSex():void{ console.log(Boy...原创 2018-08-10 23:42:16 · 257 阅读 · 0 评论 -
05.多态、抽象类
/* 多态 ts中实现多态的三要素 1、继承 2、重写 3、父类的引用指向之类对象(不是必须?) class Animal{ name:string; constructor(name:string){ this.name = name; } eat(){ } } class Dog extends Animal{ ...原创 2018-08-11 00:11:40 · 236 阅读 · 0 评论 -
06.接口
/* 接口 使用关键字interface来定义一个接口 interface FullName{ firstName:string; secondName:string; } function printInfo(info:FullName){ console.log(info.firstName +info.secondName); } printInfo({...原创 2018-08-11 01:02:04 · 1426 阅读 · 0 评论 -
07.泛型
/** 泛型 泛型的作用 :可以支持任意类型,但是也有类型检测。 要求:传入的参数和返回的参数一致。使用T代表泛型 比如,我要求一个函数,当我传入number类型的时候,它就给我返回number类型。传入string类型的时候,它就给我返回string类型,如果不用泛型的话, 大家可能会想到用any类型来解决这个问题。如 : function add(value:any):any{ ...原创 2018-08-11 14:59:36 · 435 阅读 · 0 评论