function base()
{
 .....
}
base.prototype.init=function(Name, Value)
{
this.Name=Name
this.Value=Value
}
.....
function Child(....)
{
    this.init(...)
}
Child.prototype=new base

解决方案 »

  1.   

    这是一种方法,但不是太好,因为Base类不支持初始化参数了.
    也就意味着初始化一个Base类需要两句话:var oBase = new Base();
    oBase.init('name', 'value');
    有无办法可使Base类也可以以一句话来初始化?
    var oBase = new Base('name', 'value');
      

  2.   

    <script>
    function Base(Name, Value)
    {
    this.Name = Name;
    this.Value = Value;
    }function Child(Name, Value, Type)
    {
        this.Base('p','o');
    }
    Child.prototype.Base = Base;
    var aa= new Child('p','o','i');
    </script>
      

  3.   

    <script>
    function Base(Name, Value)
    {
    this.Name = Name;
    this.Value = Value;
    }function Child(Name, Value, Type)
    {
        this.Base(Name,Value);
    }
    Child.prototype.Base = Base;
    var aa= new Child('p','o','i');
    </script>
      

  4.   

    高手, 高手.
    马上给分.顺便问一下, 请问你从哪里找到this.Base(Name,Value)这条语句的用法的,如有网址,可否告诉链接.如有书,可否告诉书名?呵呵,我喜欢寻根刨底.
      

  5.   

    不过兄弟,还是有些问题,在多层继承的时候.像下面就有问题.
    <html>
       <head>
          <title>Enter the title of your HTML document here</title>
       </head>
       <script language="javascript">
    function Base(Name, Value)
    {
    this.Name = Name;
    this.Value = Value;
    }function Child(Name, Value, Type)
    {
        this.Base(Name,Value);
        this.Type = Type;
    }
    Child.prototype.Base = Base;function Child1(Name, Value, Type, Message)
    {
        this.Child(Name, Value, Type);
    }
    var aa = new Base('p','o');
    var bb = new Child('p', 'o', 'i');
    var cc = new Child1('p', 'o', 'i', 'm');
    </script>   
       <body>
          <p>Enter the body text of your HTML document here</p>
       </body>
    </html>
      

  6.   

    不好意思,少贴了一行
    <html>
       <head>
          <title>Enter the title of your HTML document here</title>
       </head>
       <script language="javascript">
    function Base(Name, Value)
    {
    this.Name = Name;
    this.Value = Value;
    }function Child(Name, Value, Type)
    {
        this.Base(Name,Value);
        this.Type = Type;
    }
    Child.prototype.Base = Base;function Child1(Name, Value, Type, Message)
    {
        this.Child(Name, Value, Type);
    }
    Child1.prototype.Child = Child;
    var aa = new Base('p','o');
    var bb = new Child('p', 'o', 'i');
    var cc = new Child1('p', 'o', 'i', 'm');
    </script>   
       <body>
          <p>Enter the body text of your HTML document here</p>
       </body>
    </html>
      

  7.   

    csdn又出问题了?结了好久的帖子还一直在?