class Test {
person(e){
this.e = e
}
create(e){
this.ps = new this.person(e)
}
}
为什么提示 this.person is not a constructor
class Test {
person(e){
this.e = e
}
create(e){
this.ps = new this.person(e)
}
}
为什么提示 this.person is not a constructor
class Person {
constructor(name) {
this.name = name;
}
sayHello() {
console.log(`我是${this.name}`);
}
};
class Student extends Person {
constructor(name,school) {
super(name);
this.school = school;
}
printSchoolName() {
console.log(`我在${this.school}读书`);
}
};
let kun = new Student('kun', 'hha');
console.log(kun)
kun.sayHello();
kun.printSchoolName();
10 回答11.2k 阅读
5 回答4.8k 阅读✓ 已解决
4 回答3.1k 阅读✓ 已解决
2 回答2.7k 阅读✓ 已解决
3 回答2.3k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
2 回答2.6k 阅读✓ 已解决
JavaScript对象简写方法不能用作构造函数