class Student { constructor(prop) { this.name = prop.name; } hello() { alert('Hello, ' + this.name + '!'); }}class PrimaryStudent extends Student { constructor(prop) { super(prop.name); this.grade = prop.grade; } myGrade() { alert('I am at grade ' + this.grade); }}var a = new PrimaryStudent ({name:"lee",grade:100});a.hello();为什么new PrimaryStudent({name:"lee",grade:100})这里传了name的,但是访问的时候确是hello undefined?可能是我的子类出问题了?constructor里应该怎么传参数才能访问name?
添加回答
举报
0/150
提交
取消