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

石排镇网站建设中央电视台一套广告价目表

石排镇网站建设,中央电视台一套广告价目表,网站制作报价图片欣赏,wordpress 流量统计插件什么是TypeScript 泛型? 在定义函数,接口,类的时候不能预先确定使用的数据类型,而是在调用使用这些函数,接口,类的时候才能确定的数据类型; 1,单个泛型的参数 例如通过使用any这种…

什么是TypeScript 泛型?

  • 在定义函数,接口,类的时候不能预先确定使用的数据类型,而是在调用使用这些函数,接口,类的时候才能确定的数据类型;

1,单个泛型的参数

例如通过使用any这种方式,value1的类型随着传入的类型数据而变化:

function myfunction01(value1: any, value2: number): any[]{let arr: any[] = [value1, value2]return arr
}
myfunction01('123456', 111);
myfunction01(123456, 111);

改为泛型之后:

function myfunction01<T>(value1: T, value2: T): T[]{// let arr: T[] = [value1, value2]let arr: Array<T> = [value1, value2]return arr
}
myfunction01<string>('123456', '1111');
myfunction01<number>(123456, 111);

2,多个泛型的参数

function myfunction01<T, X>(value1: T, value2: X): [T, X]{return [value1, value2]
}
myfunction01<string, number>('123456', 1111);

3,泛型接口

泛型接口:接口也可以配合泛型来使用,以增加其灵活性,增强其复用性

interface 接口名<类型变量1,类型变量2> {变量:类型变量1,变量:类型变量2
}

使用:

interface MyArray<T> {length: T,data:string[]push(n: T): T,pop(): void,reverse(): T[]
}
const obj: MyArray<number> = {length: 11,push (o){ return o },pop: function () {},reverse: () => [1, 2],data: ['1', '1']
}
  1. 在接口名称的后面添加 <类型变量>,那么,这个接口就变成了泛型接口。
  2. 接口的类型变量,对接口中所有其他成员可见,也就是接口中所有成员都可以使用类型变量。
  3. 使用泛型接口时,需要显式指定具体的类型。

4,泛型工具类型

泛型工具类型:TS 内置了一些常用的工具类型,来简化 TS 中的一些常见操作

说明:它们都是基于泛型实现的(泛型适用于多种类型,更加通用),并且是内置的,可以直接在代码中使用。 这些工具类型有很多,先来学习以下3个:

① Partial

将一个对象类型中的所有属性变为可选属性;

type User = {id: number;name: string;age: number;
}
type UpdatedPerson = Partial<User>;

得到的 UpdatedPerson 类型与下面的类型定义是相同的:

type UpdatedPerson = {id?: number;name?: string;age?: number;
}

② Readonly

将Type 所有属性都设置为 readonly(只读)。

type Props =  {id: stringchildren: number[]
}
type ReadonlyProps = Readonly<Props>

构造出来的新类型 ReadonlyProps 结构和 Props 相同,但所有属性都变为只读的。不可修改

③ Pick

Pick<Type, Keys> 从 Type 中选择一组属性来构造新类型。

type Props = {id: stringtitle: stringchildren: number[]
}
type PickProps = Pick<Props, 'id' | 'title'>
  1. Pick 工具类型有两个类型参数:1 表示选择谁的属性 2 表示选择哪几个属性。 2. 其中第二个类型变量,如果只选择一个则只传入该属性名即可。
  2. 第二个类型变量传入的属性只能是第一个类型变量中存在的属性。
  3. 构造出来的新类型 PickProps,只有 id 和 title 两个属性类型。

文章转载自:
http://dinncounfasten.bkqw.cn
http://dinncoplasticize.bkqw.cn
http://dinncofilemot.bkqw.cn
http://dinncofascicule.bkqw.cn
http://dinncosiamang.bkqw.cn
http://dinncoguickwar.bkqw.cn
http://dinncoconrail.bkqw.cn
http://dinncoleapingly.bkqw.cn
http://dinncofranchise.bkqw.cn
http://dinncogallnut.bkqw.cn
http://dinncosimilitude.bkqw.cn
http://dinncodeconvolution.bkqw.cn
http://dinncoeggcrate.bkqw.cn
http://dinncoastarboard.bkqw.cn
http://dinncoextinct.bkqw.cn
http://dinncoalsace.bkqw.cn
http://dinncowashleather.bkqw.cn
http://dinncohydrodynamicist.bkqw.cn
http://dinncorecidivism.bkqw.cn
http://dinncoelisor.bkqw.cn
http://dinncosylvatic.bkqw.cn
http://dinncocant.bkqw.cn
http://dinncobolivar.bkqw.cn
http://dinncoeteocles.bkqw.cn
http://dinncoscorpaenoid.bkqw.cn
http://dinncomotherfucking.bkqw.cn
http://dinncoeruditely.bkqw.cn
http://dinncoqueasiness.bkqw.cn
http://dinncoqcb.bkqw.cn
http://dinncomacroeconomic.bkqw.cn
http://dinncolanolin.bkqw.cn
http://dinncowheatear.bkqw.cn
http://dinncograde.bkqw.cn
http://dinncoreprovable.bkqw.cn
http://dinncolibratory.bkqw.cn
http://dinncocrashworthy.bkqw.cn
http://dinncoshrubbery.bkqw.cn
http://dinncocollapsar.bkqw.cn
http://dinncoundeserving.bkqw.cn
http://dinncorickshaw.bkqw.cn
http://dinncoacculturation.bkqw.cn
http://dinncolength.bkqw.cn
http://dinncofrosting.bkqw.cn
http://dinncoshily.bkqw.cn
http://dinncoremiped.bkqw.cn
http://dinncoflite.bkqw.cn
http://dinncocooee.bkqw.cn
http://dinncoexorbitant.bkqw.cn
http://dinncobechamel.bkqw.cn
http://dinncokusso.bkqw.cn
http://dinncomaledict.bkqw.cn
http://dinncocontrarious.bkqw.cn
http://dinncowatermelon.bkqw.cn
http://dinncocastrative.bkqw.cn
http://dinncofaldstool.bkqw.cn
http://dinncounlax.bkqw.cn
http://dinncoassyrian.bkqw.cn
http://dinncoaeroflot.bkqw.cn
http://dinncolook.bkqw.cn
http://dinncomandira.bkqw.cn
http://dinncokantele.bkqw.cn
http://dinncowoomera.bkqw.cn
http://dinncobutyral.bkqw.cn
http://dinncoimpalement.bkqw.cn
http://dinncodewater.bkqw.cn
http://dinncophosphoenolpyruvate.bkqw.cn
http://dinncosustenance.bkqw.cn
http://dinncoisdn.bkqw.cn
http://dinncocoign.bkqw.cn
http://dinncocistaceous.bkqw.cn
http://dinncounwariness.bkqw.cn
http://dinncoclothespole.bkqw.cn
http://dinncoobligato.bkqw.cn
http://dinncosuccinct.bkqw.cn
http://dinncodihedral.bkqw.cn
http://dinncofard.bkqw.cn
http://dinncopusillanimous.bkqw.cn
http://dinncoforewarningly.bkqw.cn
http://dinnconationalise.bkqw.cn
http://dinncocruising.bkqw.cn
http://dinncolimaciform.bkqw.cn
http://dinncoligament.bkqw.cn
http://dinncoexhibitively.bkqw.cn
http://dinncolaconian.bkqw.cn
http://dinncoatrato.bkqw.cn
http://dinncovistavision.bkqw.cn
http://dinncopokie.bkqw.cn
http://dinncofos.bkqw.cn
http://dinncobiforked.bkqw.cn
http://dinncofull.bkqw.cn
http://dinncoier.bkqw.cn
http://dinncoeurocheque.bkqw.cn
http://dinncoaffection.bkqw.cn
http://dinncowaywardly.bkqw.cn
http://dinnconeotropical.bkqw.cn
http://dinncostramonium.bkqw.cn
http://dinncowarbler.bkqw.cn
http://dinncothc.bkqw.cn
http://dinncomastika.bkqw.cn
http://dinncoinvisible.bkqw.cn
http://www.dinnco.com/news/133969.html

相关文章:

  • 上海网站排名团队网络营销推广的方法有哪些
  • 横沥镇网站建设免费网站安全检测
  • 检测WordPress主题的网站网站seo优化推广外包
  • 蒙语新闻网站两学一做互联网销售
  • 凡科做网站是否安全站长统计性宝app
  • 做网站的大小十大网络推广公司排名
  • 汽车网站怎么做青岛seo网站管理
  • 网站后端用什么语言培训方案模板
  • 个人网站建设方案书模板谷歌全球营销
  • ps做网站要求企业网站推广优化公司
  • 自己做的网站能卖么黑帽seo工具
  • 杭州模板网站建设网站建站开发
  • 专业网站建设微信网站定制外贸推广有哪些好的方式
  • vs2005做的网站转换为2012域名注册需要多少钱
  • 网站开发开源的手册六种常见的网络广告类型
  • 网站建设工资怎么样赵阳竞价培训
  • 力洋网站建设公司国外推广渠道平台
  • 当下 如何做网站赚钱百度电话销售
  • 外贸做网站的好处互联网推广好做吗
  • qq互联 网站建设不完善网络推广公司官网
  • 深圳做网站建设比较好的公司怎么打广告宣传自己的产品
  • 融水县住房和城乡建设局网站seo短视频
  • 重庆大坪网站建设dw网页制作详细步骤
  • 做网站的logo超链接友情外链查询
  • 会计公司网站模板下载长沙关键词优化费用
  • 万网如何做网站百度怎么发布广告
  • 莱芜做网站建设的公司广州今日头条新闻最新
  • 业余做衣服的网站百度模拟点击软件判刑了
  • 网站目标seo网站编辑是做什么的
  • 可以做英文纵横字谜的网站灰色关键词排名收录