
ts
V_AYA_V
且就洞庭赊月色,将船买酒白云边
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
ts学习笔记-function
函数 函数类型 建议给每个参数添加类型之后再为函数本身添加返回值类型。 TypeScript 能够根据返回语句自动推断出返回值类型,因此通常省略。 function add(x: number, y: number) { return x + y; } 完整的函数类型包含参数定义和类型定义。 不在乎参数的名字,类型相同即认为是有效的函数类型。 当无返回值时需要定义成 void 不能省略。 赋值语句一边指定了类型,另一边没有指定类型编译器会自动识别类型。 // 完整的函数类型 let myAdd:原创 2021-06-03 14:57:46 · 747 阅读 · 0 评论 -
ts学习笔记-interface
接口 可选属性 interface SquareConfig { color?: string; width?: number; } function createSquare(config: SquareConfig): { color: string, area: number } { // ... } 额外的属性检查:跳过 interface 属性检测的方式 类型断言 添加字符串索引签名 将对象赋值给另外一个变量 // 类型断言 let mySquare = createSquar原创 2021-05-24 15:31:21 · 633 阅读 · 0 评论 -
ts学习笔记-class
TS学习-类 类的继承 当派生类中有 constructor 构造函数的时候,一定要调用 super()->执行基类的构造函数。在派生类中使用 this 之前一定要使用 super() class Animal { name: string; constructor(theName: string) { this.name = theName; } move(name: string) { console.log(`${name}说:我能移动`); } } class Dog e原创 2021-05-24 15:28:24 · 180 阅读 · 0 评论