eg:

      Function.prototype.method = function(name, func){
                this.prototype[name] = func;
                return this;
            }


            function a(){ //要添加的方法
                alert(1);
            }
            
            function A(){ //一个类
            }
            
            
            A.method("f",a);  //把添加的a方法重命名为f
            var b = new A(); //创建A的势力b
            b.f(); //b拥有了f方法。也就是a方法

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
  • 2021-07-18
  • 2021-11-30
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案