我有 3 个对象。
netBuilder 编号 NumberingMethodDefault
我有一些扩展方法。
extend: function (Child, Parent) {
var F = function () {};
F.prototype = Parent.prototype;
Child.prototype = new F();
Child.prototype.constructor = Child;
Child.superclass = Parent.prototype;
this.mixin(Child, Parent);
},
/**
* @param {type} dst
* @param {type} src
* @returns {undefined}
*/
mixin: function (dst, src) {
var tobj = {};
for (var x in src) {
if ((typeof tobj[x] == "undefined") || (tobj[x] != src[x])) {
dst[x] = src[x];
}
}
if (document.all && !document.isOpera) {
var p = src.toString;
if (typeof p == "function" && p != dst.toString && p != tobj.toString &&
p != "\nfunction toString() {\n [native code]\n}\n") {
dst.toString = src.toString;
}
}
}
比我尝试的 Numbering 从 netBuilder 扩展和 NumberingMethodDefault 从 Numbering 扩展。
oopUtility.extend(Numbering, netBuilder);
oopUtility.extend(NumberingMethodDefault, Numbering);
并调用超类
Numbering.superclass.constructor.call(this, arguments);
NumberingMethodDefault.superclass.constructor.call(this, arguments);
编号有方法 setNumber()。我可以在编号中访问 netBuilder 方法,但在 NumberingMethodDefault 中我无法从编号执行方法 setNumber()。
Uncaught TypeError: Object #<NumberingMethodDefault> has no method 'setNumber'
比我 console.log() 什么是 NumberingMethodDefault 的超类
console.log(NumberingMethodDefault.superclass);
//and it was netBuilder, not Numbering! о_О
我怎样才能让它工作。我需要扩展 3 个或更多对象!