
typescript
ts学习笔记
得知此事须躬行
心善则心安,知足必常乐!
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
vue3中钩子函数的使用案例
以获取鼠标点击位置为例子: 在hooks目录下创建useMouseEvent.ts并写鼠标点击后获取坐标的函数 然后在页面中引入函数并调用即可:原创 2021-02-26 22:35:26 · 1027 阅读 · 0 评论 -
typescript中的泛型用法
//泛型 function swap<A, B>([A, B]): [B, A] { return [B, A]; } const result = swap([1, 2]); console.log(result)//[2,1]原创 2021-02-24 14:51:57 · 309 阅读 · 0 评论 -
类与类的继承
//类 class Animal { constructor(name) { this.name = name; } run() { return `${this.name} is running` } } const snake = new Animal('lily') console.log(snake.run()) //继承 class Cat extends Animal { constructor(name) {原创 2021-02-24 14:32:46 · 108 阅读 · 0 评论 -
typescript中的接口与实现接口
//接口 interface Radio { switch(trigger: boolean): void; } //实现接口 class Car implements Radio { switch(trigger: boolean) { console.log(trigger); } }原创 2021-02-24 14:34:03 · 322 阅读 · 0 评论 -
typescript中枚举的用法
//枚举 const enum Color { Yellow = '#fff000', Blue = '#01ccff', Red = '#ff0000' } let c: Color = Color.Red; console.log(c);// #ff0000原创 2021-02-24 14:43:57 · 589 阅读 · 0 评论