
typescript
L时光
这个作者很懒,什么都没留下…
展开
-
typescript学习笔记-命名空间和模块
模块化开发,一个模块就是一个实现特定功能的文件,typescript可以通过export(暴露)和import(获取暴露的方法)来实现export//方法一 export function getData(){ console.log('获取数据成功!');}export function setData(){ console.log('设置数据成功!');}//方法二function getData(){ console.log('获取数据成功!'.原创 2021-07-21 16:45:57 · 209 阅读 · 0 评论 -
typescript学习笔记-泛型
函数泛型://函数泛型function fun<T>(value:T):T{ return value;}console.log(fun<string>('测试函数泛型'));console.log(fun<number>(123));// 类泛型class minClass<T>{ public arr:T[]=[]; constructor(arr:T[]){ this.arr=arr;原创 2021-07-20 17:34:50 · 185 阅读 · 0 评论 -
typeScript学习笔记-接口
//参数接口 设定一个标准,这个参数以后只能传这两个参数interface FnName{ name:string; age:number;}function getName(obj:FnName):void{ console.log(obj,'obj');}getName({name:'张三',age:24});//函数接口interface Fun{ (name:string):string}let getName1:Fun=function(.原创 2021-07-19 19:04:03 · 182 阅读 · 0 评论 -
typescript学习笔记-类
class Animal{ publie name:string;//公共的 private age:number;//私有的 只有自己可以使用 protected sex:string; //保护的,自己和子类可以使用 publie color:string //构造函数 name age默认为10 sex默认为男 color ?代表可选 constructor(name:string,age:number=10,sex:string='男',colo.原创 2021-07-19 13:45:52 · 180 阅读 · 0 评论