![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ts
啥也不会的程序辕
这个作者很懒,什么都没留下…
展开
-
typescript 学习 系列 (六)
// 1.abstract 抽象类:就是把共用的东西进行封装。 只能被继承,不能实例化 abstract class chouxiangA { name :string = '抽象类'; // 就是你知道下面类中都有这个方法,但是你不知道方法里具体写什么。这样的话定义abstract abstract getName() :string } // 类一 class chouxiangB extends chouxiangA{ ge原创 2021-07-11 22:29:03 · 132 阅读 · 0 评论 -
typescript 学习 系列 (五)
1.class 构造器 constructor //知识点一 class GouzhaoqiA { //正常写法 /*public name:string; constructor(name:string){ this.name = name }*/ //简便写法 constructor(public name:string){ this.name = name; } } var gouzhoaqiB = new GouzhoaqiA('构造器')原创 2021-06-27 00:15:43 · 110 阅读 · 0 评论 -
typescript 学习 系列(三)
1. interface 和 type 类型别名 //(1)interface interface a{ x:number, y:string } //给这个变量加上类型注解 var b:a = { x:1, y:'2' }; /*还可以添加一些属性 1.readonly 是一个只读属性 2. ? 添加问号,可以规定这个属性可以不定义, 3. [prposName :string]:any 如果你不确定原创 2021-05-10 00:14:32 · 84 阅读 · 0 评论 -
typescript 学习 系列(二)
1.函数类型相关 //(1) 函数返回值的规定 function hanshuA():number{ console.log('规定函数返回值为数字') return 1 } function hanshuB():void{ console.log('void规定函数没有返回值') } function hanshuC():never{ throw new Error() console.log('never规原创 2021-05-08 23:48:42 · 80 阅读 · 0 评论 -
typescript 学习 系列(一)
1.静态类型 //(1)基本类型undefined null number string boolean symbol void) //注意:当设置为string类型后,后续就不能在赋值不同类型的数据 var num:string = '123'; //比如:设置数字(报错:不能将类型“string”分配给类型“number”。) num = 123; //(2)对象类型 var duixiangA:{a:number,b:string}={a:1,b:"3"} //对象 v原创 2021-05-07 23:03:30 · 83 阅读 · 0 评论