# 类的定义
实例上的属性需要先声明在使用,构造函数中的参数可以使用可选参数和剩余参数
class Pointer {
x!:number // 实例上的属性必须先声明
y!:number
constructor(x, y) { // 构造函数也是函数
this.x = x
this.y = y
}
}
const point = new Pointer(1, 2)
console.log(point);
# 类的修饰符
# 静态属性和方法
# 类的装饰器
← 函数