只能模拟一下。因为是模拟的,所以私有方法和属性继承不出来。
<SCRIPT LANGUAGE="JavaScript">
<!--
function myObj(p1,p2){
this.a=p1;
this.b=p2;
this.test=myObj_method;
}
function myObj_method(){
alert(this.a+"\n"+this.b);
}function child(p1,p2){
var o = new myObj(p1,p2);
for (var i in o){
this[i] = o[i];
}
}var o = new child("Hello","world");
o.test();
//-->
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
<!--
function myObj(p1,p2){
this.a=p1;
this.b=p2;
this.test=myObj_method;
}
function myObj_method(){
alert(this.a+"\n"+this.b);
}function child(p1,p2){
var o = new myObj(p1,p2);
for (var i in o){
this[i] = o[i];
}
}var o = new child("Hello","world");
o.test();
//-->
</SCRIPT>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货