当前位置: 首页 > news >正文

怎样做网站安全测试seo是什么牌子

怎样做网站安全测试,seo是什么牌子,百度不收录网站描述,张雪峰谈建筑学前景接口是对类的一部分行为的抽象 类类型 实现接口 为什么不是描述类呢?而是类一部分行为的抽象? 类中分为:静态部分(构造器)、实例部分(类成员)。 类成员:实例的属性、原型上的方…

接口是对类的一部分行为的抽象

类类型

实现接口

为什么不是描述类呢?而是类一部分行为的抽象?

类中分为:静态部分(构造器)、实例部分(类成员)。

  • 类成员:实例的属性、原型上的方法。
    • 接口就是为了修饰类成员
  • 静态部分:constructor
    • 构造函数是不能通过接口实现的,接口实现的是构造函数实例化的对象。

类的本质是构造函数,构造函数上没有类成员,所以接口不能描述类,而是说类实现的这个接口。

类实现的这个接口:接口描述属性,在类中去具体实现。

接口描述了类的公共部分

总结:修饰类需要写两个接口 + 一个函数:一个接口用来修饰类成员,一个接口用来修饰类构造函数本身,用一个函数把两者合并。

interface IPerson {name: string;sayName: (a: string) => void;
}interface IPersonCons {new (a: string): IPerson;hobby: string;sayHobby: (b: string) => void;
}class Person implements IPerson {name ='123';sayName(c: string) {console.log(this.name, c);}constructor(a:string) {this.name = a;};static hobby = '123';static sayHobby (b: string){console.log(this.hobby, b);}
}function createPerson(c:IPersonCons): IPerson{return new c('zhangsan');
}let person =  createPerson(Person);
console.log(person.name); //zhangsanperson.sayName('white'); //zhangsan white
person.sayName('white'); //zhangsan whiteconsole.log(Person.hobby); //'123'
Person.sayHobby('baskstball'); //'123 baskstball'

如果没有静态属性,函数可以怎么写?

interface IPerson {name: string;sayName: (a: string) => void;//简写上面:sayName();
}
class Person implements IPerson {name ='123';sayName(c: string) {console.log(this.name, c);}constructor(a:string) {this.name = a;};
}
//写法1
function createPerson(c:{new (a: string): IPerson;}): IPerson{return new c('zhangsan');
}
//写法2
function createPerson(c:new (a: string) => IPerson): IPerson{return new c('zhangsan');
}
//写法3
// 抽象泛型,T可以理解为一个泛型变量,属于类型变量,这里属于IPerson,接口继承接口,实现接口的抽象
function createPerson <T extends IPerson>(c:new (a: string) => T): T{return new c('zhangsan');
}

注意两个ts配置:

"strictNullChecks": true,                         /* When type checking, take into account 'null' and 'undefined'. */
"strictPropertyInitialization": true,             /* Check for class properties that are declared but not set in the constructor. */

接口继承接口

接口继承接口,相当于接口的拓展。

interface Shape {color: string;
}interface Square extends Shape {sideLength: number;
}let a:Square = {color: 'white',sideLength: 60
}

一个接口可以继承多个接口,创建出多个接口的合成接口。

interface Shape {color: string;
}interface PenStroke {penWidth: number;
}interface Square extends Shape, PenStroke{sideLength: number;
}let a:Square = {color: 'white',sideLength: 60,penWidth: 30
}

type是类型别名,给交叉类型赋别名

type ShapeAndPenStroke = Shape & PenStroke
interface Square1 extends ShapeAndPenStroke{sideLength: number;
}

交叉类型:两个都包括:Shape & PenStroke

联合类型:两个取其一:Shape | PenStroke

类型断言

清楚地知道一个实体的类型,在赋值时人为确定类型,不需要ts进行类型推断。

两种写法:

  • as类型

  • <类型>

interface Shape {color: string;
}interface PenStroke {penWidth: number;
}interface Square extends Shape, PenStroke {sideLength: number;
}// let square = <Square>{};
let square = {} as Square;
square.color = "blue";
square.sideLength = 10;
square.penWidth = 5.0;

混合类型

混合类型:一个接口中有函数、有属性

interface Counter {(start: number): string;interval: number;reset(): void;
}function getCounter(): Counter {let counter = <Counter>function (start: number) { };counter.interval = 123;counter.reset = function () { };return counter;
}let c = getCounter();
c(10);
c.reset();
c.interval = 5.0;
http://www.hkea.cn/news/119533/

相关文章:

  • 常州网站建设案例网站制作建设公司
  • 外国人做家具的网站一站传媒seo优化
  • 佛山h5建站模板怎样优化网站
  • 第三方做公司网站谷歌搜索广告优化
  • 网站风格模板快速排名精灵
  • 做网站横幅 的网站推荐几个公司推广
  • html5国内网站建设客户管理软件
  • 网站建设报价单站长工具 seo查询
  • 日本电商网站贵州快速整站优化
  • 物业服务网站建设建立网站要多少钱一年
  • 中铁建设门户加长版廊坊百度提升优化
  • 最便宜的外贸网站建设电商平台运营方案
  • 做网站应该会什么问题网络营销软文范例500字
  • 摄影网课百度关键词优化查询
  • 打广告型的营销网站西安百度推广外包
  • 乌鲁木齐招聘网站建设一站式网络营销
  • 中小型网站建设服务淘宝数据分析工具
  • 梧州网站设计企业网站模板建站
  • 行政事业单位网站建设建议营销策划公司
  • 网络推广网站怎么做百度联盟广告点击一次收益
  • wordpress居中样式宁波seo网络推广外包报价
  • java做网站用到哪些技术网络营销的重要性与意义
  • 网络营销推广的作用谷歌seo什么意思
  • 免费网站建设解决方案郑州网络营销公司哪个好
  • 转转怎么做钓鱼网站税收大数据
  • 株洲专业网站排名优化深圳产品网络推广
  • 深圳美食教学网站制作如何免费搭建自己的网站
  • 兰州移动端网站建设广东整治互联网霸王条款
  • 彩票网站该怎么建设天津seo实战培训
  • 原平的旅游网站怎么做的新冠疫情最新情况最新消息