好的,所以我尝试使用以下语法:
function ConstructorTest(value1, value2, value3, value4) {
this.key1= value1;
this.key2= value2;
this.key3= value3;
this.key4= value4;
}
ConstructorTest.prototype = {
future: function() {
console.log(something);
}
}
const constTest = ConstructorTest("Key1", "Key2", "Key3", "Key3");
constTest.future();
而不是像这样分配它:
ConstructorTest.prototype.future = function() {}
因此它说:无法读取未定义的属性“未来”,无法弄清原因。