在定义子类时,我得到了 TypeErorr:undefined for constructor 参数,正如我所见,它充当占位符。到底发生了什么以及如何解决?
function Class(object) {
this.name = object.name;
}
var myClass = new Class({
name: "ClassName"
})
console.log(myClass.name);
function SubClass(object) {
this.name = object.name;
}
SubClass.prototype = new Class();
SubClass.prototype.constructor = SubClass;
var mySubClass = new SubClass({
name: "SubClassName"
})
//TypeError: 对象未定义