//基本示例class Person { name: string; age: number; //构造函数 constructor(name: string, age: number) { this.name = name; this.age = age; } sayHello() { console.log(this.name); }}let zs: Person = new Person('张三', 18);