为了账号安全,请及时绑定邮箱和手机立即绑定

ES6语法练习,继承,Cannot read property 'name' of undefined

ES6语法练习,继承,Cannot read property 'name' of undefined

/*  * Programming Quiz: Building Classes and Subclasses (2-3)  */ class Vehicle {  constructor(color = 'blue', wheels = 4, horn = 'beep beep') {   this.color = color;   this.wheels = wheels;   this.horn = horn;  }  honkHorn() {   console.log(this.horn);  } } // your code goes here class Bicycle extends Vehicle {     constructor(color, wheels, horn){         super(Vehicle);         this.wheels = 2;         this.horn = 'honk honk';         this.color = 'blue';     } } const myVehicle = new Vehicle(); myVehicle.honkHorn(); // beep beep const myBike = new Bicycle(); myBike.honkHorn(); // honk honk测试答案如下报错如下为什么说Cannot read property 'name' of undefined?
查看完整描述

2 回答

已采纳
?
橋本奈奈未

TA贡献436条经验 获得超108个赞

编译器的问题?我这边是可以的。你试试super()不传参数试试呢

查看完整回答
反对 回复 2017-08-20
?
smileying

TA贡献1条经验 获得超0个赞

class Bicycle extends Vehicle {

   constructor(color, wheels = 2, horn = 'honk honk'){

       super(color,wheels,horn);

   }  

}


查看完整回答
反对 回复 2017-11-25
  • 2 回答
  • 0 关注
  • 3085 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信