function Parent() {
this.Method = function() {
alert("Parent Method");
};
}; function Son() {
Parent.call(this); this.Method = function() {
alert("Son Method");
(new Parent()).Method.call(this);
};
}; function Grandson() {
Son.call(this);
this.Method = function(){
alert("Grandson Method");
(new Son()).Method.call(this);
};
};
调用 Son的method是成功的,
var s = new Son();
s.Method();
调用 Grandson的Method的失败,
var g = new Grandson();
g.Method();
this.Method = function() {
alert("Parent Method");
};
}; function Son() {
Parent.call(this); this.Method = function() {
alert("Son Method");
(new Parent()).Method.call(this);
};
}; function Grandson() {
Son.call(this);
this.Method = function(){
alert("Grandson Method");
(new Son()).Method.call(this);
};
};
调用 Son的method是成功的,
var s = new Son();
s.Method();
调用 Grandson的Method的失败,
var g = new Grandson();
g.Method();
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货