在其他浏览器中,我可以从__proto__属性调用父方法。但它在IE8中不起作用。在IE8中有调用父方法的方法吗?
代码示例:
function Foo() {
this.init = function (msg) {
alert("super method invoked");
};
this.toString = function () {
return "Foo";
}
}
FooExtended.prototype = new Foo();
function FooExtended() {
this.init = function (msg) {
if (this.__proto__ == undefined) {
alert("super invoke not supported")
} else {
this.__proto__.init(msg);
}
};
this.toString = function () {
return "FooExtended";
}
}
var foo = new FooExtended();
foo.init();发布于 2013-09-21 11:11:21
而不是
this.__proto__.init(msg)试一试
Foo.prototype.init.apply(this, msg);https://stackoverflow.com/questions/18931833
复制相似问题