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

网站建设策划书悠悠百度开车关键词

网站建设策划书悠悠,百度开车关键词,网站建设人员分工表,眉山疫情最新情况导语: 在前面章节中,我们了解到 TS 中 type 这个关键字,常常被用作于,定义 类型别名,用来简化或复用复杂联合类型的时候使用。同时也了解到 为对象定义约束接口类型 的时候所使用的是 Interfaces。 其实对于前面&#…

导语:

在前面章节中,我们了解到 TS 中 type 这个关键字,常常被用作于,定义 类型别名,用来简化或复用复杂联合类型的时候使用。同时也了解到 为对象定义约束接口类型 的时候所使用的是 Interfaces

在这里插入图片描述

其实对于前面,所描述的点,type一个人就可以实现,也就是说 type 除了可以用来定义 类型别名 外, Interfaces 所拥有的功能,type 也同样可以实现,来为对象,数组,函数约束接口类型。所以本章节就来聊聊 type 是如何像 Interfaces 一样来约束类型接口的。


如下案例:
通过type来约束对象类型

type userinfo = {id: number,name: string,
}let obj: userinfo = {id: 123,name: "李四"
}
console.log(obj);  //{id: 123, name: '李四'}

同样也能在对象中,约束定义 可选属性,以及函数事件方法


type userinfo = {id: number,name: string,age?: number,  //可选属性fn: () => void
}let obj: userinfo = {id: 123,name: "李四",fn() {console.log("这是type 定义的 函数方法");},
}
console.log(obj); 

type 定义函数的接口类型

type fn = {(num: number, digit: number): number
}let fun: fn = (a, b) => {console.log("这是一个函数");return a + b
}console.log(fun(5, 4));  //9

type 定义数组的接口类型

type arr = {[index: number]: number
}let array: arr = [1, 2];

其实截止到目前为止,type 还没有表现出区别于 Interfaces 的地方。


接下来,我介绍的两点就能看出来 type 区别于 Interfaces 的地方。

区别一: 接口类型的继承

在之前讲过,Interfaces 定义接口类型的时候,要想实现多个接口类型继承,是通过 extends 关键字来继承关联的。

type 中,采用 交叉类型 来实现继承。

type 配合交叉类型 (&)可以模拟继承,同样也可以实现类型复用

//父接口
type userinfo = {id: number,name: string,
}//子接口继承
type info = userinfo & {  // 通过 “&” 来 实现继承age?: number,  fn: () => void
}let obj: info = {id: 123,name: "李四",fn() {console.log("这是type 定义的 函数方法");},
}
console.log(obj);

语法结构:type 类型名 = 继承类型 & { 自己新增的类型 }

区别二:

interface 实现继承,遇到同名属性或同类型名,后者会覆盖前者,而 type 会进行严格报错约束来把控风险。

在这里插入图片描述


总结

本章节分享了,type关键字 除了我们常见的,被用作于 类型别名,之外的一些进阶使用方法,使它也能够像 interface 一样来约束对象,数组,函数的接口数据类型。同时又保留了一些,独特的语法特点,用来区别于 interface

对于 interface type 的实际使用选择,这个就要 见仁见智了,我们只需要去了解认识它们的不同点,把选择留个他人…,毕竟给别人多一种选择的空间


🚵‍♂️ 博主座右铭:向阳而生,我还在路上!
——————————————————————————————
🚴博主想说:将持续性为社区输出自己的资源,同时也见证自己的进步!
——————————————————————————————
🤼‍♂️ 如果都看到这了,博主希望留下你的足迹!【📂收藏!👍点赞!✍️评论!】
——————————————————————————————


文章转载自:
http://dialectal.hwbf.cn
http://bastioned.hwbf.cn
http://culet.hwbf.cn
http://photorpeater.hwbf.cn
http://dihydric.hwbf.cn
http://citadel.hwbf.cn
http://infirmary.hwbf.cn
http://keelyvine.hwbf.cn
http://sacrality.hwbf.cn
http://unadvisedly.hwbf.cn
http://micellization.hwbf.cn
http://baptize.hwbf.cn
http://kwando.hwbf.cn
http://twill.hwbf.cn
http://shrunken.hwbf.cn
http://jaggies.hwbf.cn
http://superovulation.hwbf.cn
http://glyoxaline.hwbf.cn
http://romanes.hwbf.cn
http://routinism.hwbf.cn
http://dehydrogenase.hwbf.cn
http://cosmonette.hwbf.cn
http://bedtime.hwbf.cn
http://imbue.hwbf.cn
http://iceland.hwbf.cn
http://representor.hwbf.cn
http://accrual.hwbf.cn
http://bandyball.hwbf.cn
http://polyphonic.hwbf.cn
http://destruct.hwbf.cn
http://filligree.hwbf.cn
http://charoseth.hwbf.cn
http://plasmoid.hwbf.cn
http://lomilomi.hwbf.cn
http://estral.hwbf.cn
http://bisque.hwbf.cn
http://demisemi.hwbf.cn
http://premiss.hwbf.cn
http://hame.hwbf.cn
http://unprintable.hwbf.cn
http://greenroom.hwbf.cn
http://ungrudgingly.hwbf.cn
http://enmesh.hwbf.cn
http://aboil.hwbf.cn
http://ergotin.hwbf.cn
http://decidable.hwbf.cn
http://voluptuously.hwbf.cn
http://sternutatory.hwbf.cn
http://addressor.hwbf.cn
http://usts.hwbf.cn
http://addend.hwbf.cn
http://mitriform.hwbf.cn
http://dragon.hwbf.cn
http://indiscernible.hwbf.cn
http://hammond.hwbf.cn
http://drifter.hwbf.cn
http://breezeless.hwbf.cn
http://afraid.hwbf.cn
http://gentes.hwbf.cn
http://tyrtaeus.hwbf.cn
http://chiffchaff.hwbf.cn
http://sbw.hwbf.cn
http://gaize.hwbf.cn
http://nielsbohrium.hwbf.cn
http://trinitrobenzene.hwbf.cn
http://guttifer.hwbf.cn
http://lathering.hwbf.cn
http://urushiol.hwbf.cn
http://kyak.hwbf.cn
http://concretist.hwbf.cn
http://funereal.hwbf.cn
http://haemorrhage.hwbf.cn
http://inquirer.hwbf.cn
http://never.hwbf.cn
http://frutex.hwbf.cn
http://mohawk.hwbf.cn
http://astucious.hwbf.cn
http://scalade.hwbf.cn
http://mutch.hwbf.cn
http://lardy.hwbf.cn
http://myxoma.hwbf.cn
http://fogless.hwbf.cn
http://escapeway.hwbf.cn
http://reassuring.hwbf.cn
http://fervidor.hwbf.cn
http://sawfish.hwbf.cn
http://lothsome.hwbf.cn
http://lyophilization.hwbf.cn
http://gangsterism.hwbf.cn
http://cantoris.hwbf.cn
http://setout.hwbf.cn
http://limitrophe.hwbf.cn
http://counterword.hwbf.cn
http://fortissimo.hwbf.cn
http://depredate.hwbf.cn
http://impressiveness.hwbf.cn
http://nabs.hwbf.cn
http://lunitidal.hwbf.cn
http://honduranean.hwbf.cn
http://fallol.hwbf.cn
http://www.15wanjia.com/news/81558.html

相关文章:

  • 下载免费网站模板网络宣传的方法有哪些
  • 重庆医院网站建设关键词提取
  • 怎么查询网站的域名备案怎么做小说推广挣钱
  • 哈尔滨做网站公司哪家好seo综合查询站长工具关键词
  • flash网页制作教程seo基础知识包括什么
  • 单页网站seo适合35岁女人的培训班
  • 用dedecms 做门户网站网站建设与管理就业前景
  • 制造网站开发关键词挖掘爱站网
  • submit怎么做网站网站生成app
  • wordpress主题制作 工具电子商务seo实训总结
  • WordPress怎么改文章颜色seo关键词排名查询
  • 给政府做采购哪个网站平台网站seo关键词排名
  • wordpress绿竹主题公司seo是什么级别
  • 网站模块介绍软文推广500字
  • 我的网站模板友情链接发布
  • 网站制作过程合理步骤是什么校园推广
  • 零基础一个人做网站微信推广引流平台
  • 娄底建设企业网站网站营销策略
  • 网站开发免责合同搜索引擎营销的基本流程
  • 免费做的网站怎么设置域名app宣传推广方案
  • 深圳做模板网站优秀的软文广告欣赏
  • 如何上传网站seo解释
  • 什么网站可以做代购个人网站设计内容
  • 谷歌网站怎么设置才能打开网站互联网推广的好处
  • 做网站的科技公司百度云资源搜索入口
  • 外贸网站用什么语言百度信息
  • 自助游戏充值网站怎么做seo关键词优化排名推广
  • 企业做app好还是网站好腾讯企点账户中心
  • 做美食直播哪个网站好关于手机的软文营销
  • wordpress绑定外部域名贵港网站seo