在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
泛型: 参数化的类型,一般用来限制结合的内容 class Student { constructor(public name: string) { } say() { console.log(this.name + " saying"); } } class HighSchoolStudent extends Student { constructor(name: string, no: string) { super(name) } no:string; study() { super.say(); } } var students: Array<Student> = []; students[0] = new Student("zhangsan"); students[1] = new HighSchoolStudent("lisi","06169010"); 泛型 var students: Array<Student> = []; 用来定义数组只用是Student元素 |
请发表评论