日期:2014-05-16  浏览次数:20378 次

call实现override函数的调用问题
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();

------解决方案--------------------
没有问题啊
------解决方案--------------------
http://jsfiddle.net/3tn9J/