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.
 
 
 
 
 

23 lines
504 B

// 类的两种继承方式:1.extends(继承父类) 2.implements(实现接口)
// 父类
class Animal {
move() {
console.log('666')
}
}
// 第一种:extends(继承父类)
// 子类 Dog 继承 父类 Animal,子类 Dog 具有父类 Animal 的属性和方法
class Dog extends Animal {
// 子类自己的属性和方法
name = 'Max'
brak() {
console.log('8888')
}
}
// 实例化子类 Dog
const d = new Dog()
d.move()
d.brak()
console.log(d.name)