You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
391 B

// 接口
interface Singable {
sing(): void
name: string
}
// 使用 implements 关键字让 class 实现接口
// Person 类实现接口 Singable , 意思是 Person 类中必须提供 Singable 接口中指定的所有方法和属性
class Person implements Singable {
name = 'jack'
sing() {
console.log('666666')
}
}
const p = new Person()
console.log(p.name)