react18-学习笔记12-类class

阅读 142

2022-08-27

class Animal{
protected name: string;
static age=18
constructor (name:string){
this.name=name
}
run(){
return `${this.name}`
}
}
const snake=new Animal("geyao")
console.log(Animal.age)
class Dog extends Animal{
bark(){
return `${this.name}`
}
}
const dog=new Dog("geyao")

class Cat extends Animal{
bark(){
return `${this.name}`
}
}
const cat=new Cat("geyao")



精彩评论(0)

0 0 举报