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.

17 lines
413 B

2 years ago
  1. // 成员可见性:让父类的方法或属性让子类成员可以使用
  2. // 可见性修饰符: public,表示公开的、公有的,公有成员可以被任何地方访问。public 是默认可见性,可以省略。
  3. // 父类
  4. class Animal {
  5. public move() {
  6. console.log('123')
  7. }
  8. }
  9. // 子类
  10. class Dog extends Animal {
  11. bark() {
  12. console.log('88888')
  13. }
  14. }
  15. const d = new Dog()