首页 > 其他分享 >react18-学习笔记12-类class

react18-学习笔记12-类class

时间:2022-08-26 20:46:25浏览次数:141  
标签:12 geyao name react18 Animal return class const

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")

标签:12,geyao,name,react18,Animal,return,class,const
From: https://www.cnblogs.com/yao-655442/p/16629136.html

相关文章