对类的使用:
class Person {
name:string;
age: number;
constructor(name:string, age:number){
this.name = name;
this.age = age;
}
print () {
return this.name + ':' + this.age;
}
}
var p = new Person("小宝", 19);
p.print(); // "小宝:19"
网友评论