在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
简单的定义 const numArr:number[]=[1,2,3] const strArr:string[]=['a','b','c'] const undeArr:undefined[]=[undefined,undefined] 数组中有字符串又有数组的类型 const arr:(number|string)[]=[1,'a',2] 数组中对象的定义 const xiaojie:{name:string,age:number}[]=[ {name:"小妹",age:18} ] 或者用别名type type lady={name:string,age:number} const xiaojiejie:lady[]=[ {name:'韩云',age:18} ] 用class也行 class Madam{
name:string;
age:number;
}
const dajiejie:Madam[]=[]
元祖 const dajiejie:[string,string,number]=['dajiao','teach',29]
|
请发表评论