typescript多维对象数组仿List泛型
程序员文章站
2022-07-03 10:26:34
定义对象: 二维对象数组: 多维数组: 任意类型数组: 泛型类: ......
定义对象:
namespace entity{ export class MyClass{ public value:number; public rect:string; public constructor(){ } } }
二维对象数组:
let myClass= new Array<Array<entity.MyClass>>();
多维数组:
let myArray: number[][][][] = []
任意类型数组:
let myArray:any[]=[]; myArray[0]=[{key:1,keyA:"a"},[1,2]]; let arr = [{key:1,keyA:"a"},[1,2]];
泛型类:
namespace entity{ export class MyClass<T>{ public myArray:T[]; public constructor(){ } } }