日期:2014-05-16 浏览次数:20338 次
<script type="text/javascript"> function S(){ } S.prototype.s = "s"; S.prototype.s1 = "s1"; function C(){ this.c = "c"; this.c1 = "c1"; } Ext.extend(C,S,{s1:"by c overload"}); var c = new C(); alert(c.s); //s alert(c.s1); //by c overload </script>
//如果按下面这个方式写就会提示c.s没有定义(undefind) <script type="text/javascript"> function S(){ this.s = "s"; this.s1 = "s1"; } function C(){ this.c = "c"; this.c1 = "c1"; } Ext.extend(C,S,{s1:"by c overload"}); var c = new C(); alert(c.s); //undefind alert(c.s1); //by c overload </script>
//也可以通过如下方式来实现类的继承 <script type="text/javascript"> function S(){ } S.prototype.s = "s"; S.prototype.s1 = "s1"; C = Ext.extend(S,{s1:"by c overload"}); var c = new C(); alert(c.s); //s alert(c.s1); //by c overload </script>