12 2020 档案
react带ts创建
摘要:npx create-react-app my-app --template typescript 阅读全文
posted @ 2020-12-11 11:17 chenlw101 阅读(457) 评论(0) 推荐(0) 编辑
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 阅读(322) 评论(0) 推荐(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 阅读(65) 评论(0) 推荐(0) 编辑
ts-枚举
摘要:const enum Direction { Up='Up', Down="Down", Left="Left", Right="Right" } console.log(Direction.Up) 阅读全文
posted @ 2020-12-10 19:06 chenlw101 阅读(44) 评论(0) 推荐(0) 编辑
ts-类与接口
摘要:interface Radio{ switchRadio(triggrL:boolean):void; } interface Bettery{ checkBettery(); } interface RadioAndBettery extends Radio{ checkBettery(); } 阅读全文
posted @ 2020-12-10 18:58 chenlw101 阅读(91) 评论(0) 推荐(0) 编辑
ts-类
摘要:class Person { // 默认public //private私有,不可访问 //protected子类可以访问,外部不可以访问 // readonly 只可读,不可写 // static 静态属性 当类的定义与实例状态没有太大关系的时候使用 protected name:string; 阅读全文
posted @ 2020-12-10 17:33 chenlw101 阅读(47) 评论(0) 推荐(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 阅读(982) 评论(0) 推荐(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 阅读(74) 评论(0) 推荐(0) 编辑
express访问外部url,get/post
摘要:var request = require('request'); var qs=require( 'querystring' ); // 发起请求 var httpRequest = function (url,data=null,method="GET",headers={}){ return 阅读全文
posted @ 2020-12-02 11:10 chenlw101 阅读(499) 评论(0) 推荐(0) 编辑


点击右上角即可分享
微信分享提示