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")
react18-学习笔记12-类class
最新推荐文章于 2024-07-10 22:11:08 发布