
获得徽章 0
- #沸你不可# 队伍名称:前端沸才小组
成员:@阿白756 @iwin621 @xn213
今日学习:
extends 继承 在react 中最熟悉的语法,
class Child extends Component { // ... }
而在vue2.x 中使用的还是不是那么多,
class Parent { // 定义父类
constructor (name, age) {
this.name = name;
}}
class Child extends Parent { // 定义子类,子类继承父类
constructor (...arg) {
// 通过super继承父类的属性和方法
// 必须通过super继承后,才能使用子类自己的this
// 否则报错,得不到子类的this对象
super(...arg); // es5的实现方式Parent.apply(this, arg)
// this.name = name; }}展开评论1