就是一个类a包含基本的方法属性
然后另一个类b在a的基础上进行扩展

解决方案 »

  1.   

    我也show一下 ^.^在Class层次上"继承"<script type="text/javascript">
    function BaseClass(str){
    this.Message = str || "Hello Wrold!";
    this.ShowMessage = function(){
    alert(this.Message);
    }
    }function ExtendClass(str){
    this.Message2 = str || "Hello Wrold!";
    this.ShowMessage2 = function(){
    alert(this.Message2);
    }
    }ExtendClass.prototype = new BaseClass();//Test Driver
    var ExtendInstance = new ExtendClass("From Extend Class");
    ExtendInstance.ShowMessage2();
    ExtendInstance.ShowMessage();
    </script>
    在Object层次上"继承"<script type="text/javascript">
    Object.prototype.Extend = function(Base,Args){
    if(Args instanceof Array) Base.apply(this,Args);
    else Base.call(this,Args);
    }function BaseClass(str){
    this.Message = str || "Hello Wrold!";
    this.ShowMessage = function(){
    alert(this.Message);
    }
    }function ExtendClass(str){
    this.Message2 = str || "Hello Wrold!";
    this.ShowMessage2 = function(){
    alert(this.Message2);
    }
    }//Test Driver
    var ExtendInstance = new ExtendClass("From Extend Class");
    ExtendInstance.Extend(BaseClass,"From Base Class");
    ExtendInstance.ShowMessage2();
    ExtendInstance.ShowMessage();
    </script>