class Point<T>{
x:T
y:T
z:T
constructor(x:T,y:T,z:T) {
this.x=x
this.y=y
this.z:z
}
}
const p=new Point('123','23','231')//类型推导
const p2=new Point<sring>('123','23','231')
const p3:Point<sring>=new Point('123','23','231')
const p4:sring[]=['123','23','231']
const p5:Array<string>=['123','23','231']//开发不推举
ts泛型的类
最新推荐文章于 2024-10-29 23:14:09 发布