我在使用Javascript扩展类时面临一些问题, 我已经创建了一个我想要扩展的类,然后我已经通过call()方法调用父,但我有一个错误,有人可以告诉我如何或什么是扩展和覆盖方法的正确方法?
AbstractObject
var AbstractObject= (function () {
function AbstractObject() {
var elements = {};
var containerKey = null;
var self = this;
this.getElementByKey = function (key) {
var object = elements[key];
//if exist
if (object.length == 1) {
return object;
}
return null;
};
var __construct = function (that) {
self.__construct();
}(this);
}
AbstractObject.prototype = {
__construct: function () {
console.log('const');
}
};
return AbstractObject;
})();
父类
var Parent = (function () {
function Parent() {
AbstractObject.call(this);
}
Parent.prototype = {};
return Parent;
})();
错误
TypeError: self.__construct is not a function [Learn More] AbstractObject.js
先谢谢