ts-类型别名、类型断言
摘要:// 类型别名 type PlusType = (x:number,y:number)=>number function sum(x:number,y:number):number{ return x+y } const sum2:PlusType = sum type NameResolver =
阅读全文
posted @
2020-12-10 20:08
chenlw101
阅读(325)
推荐(0)
ts-泛型
摘要:function echo<T>(arg:T):T{ return arg } const result = echo("str") function swap<T,U>(arr:[T,U]):[U,T]{ return [arr[1],arr[0]] } const result1 = swap(
阅读全文
posted @
2020-12-10 19:56
chenlw101
阅读(68)
推荐(0)
ts-枚举
摘要:const enum Direction { Up='Up', Down="Down", Left="Left", Right="Right" } console.log(Direction.Up)
阅读全文
posted @
2020-12-10 19:06
chenlw101
阅读(50)
推荐(0)
ts-类与接口
摘要:interface Radio{ switchRadio(triggrL:boolean):void; } interface Bettery{ checkBettery(); } interface RadioAndBettery extends Radio{ checkBettery(); }
阅读全文
posted @
2020-12-10 18:58
chenlw101
阅读(93)
推荐(0)
ts-类
摘要:class Person { // 默认public //private私有,不可访问 //protected子类可以访问,外部不可以访问 // readonly 只可读,不可写 // static 静态属性 当类的定义与实例状态没有太大关系的时候使用 protected name:string;
阅读全文
posted @
2020-12-10 17:33
chenlw101
阅读(51)
推荐(0)
ts interface、函数
摘要:interface Person { readonly id:number; name:string; age?:number; } function add(x:number=2,y:number,z?:number):number{ if(typeof z "number"){ return x
阅读全文
posted @
2020-12-10 17:09
chenlw101
阅读(986)
推荐(0)
ts:类型
摘要:let isDone:boolean = true let age:number = 123 let newName:string = "aaa" let u:undefined = undefined let n:null = null; let uDemo:number=null let uDe
阅读全文
posted @
2020-12-10 17:04
chenlw101
阅读(80)
推荐(0)