javascript的继承 var a=function(){ this.click=function() { alert("A"); }}var b =function(){}b.prototype=new A; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 要用脚本模拟:function test(){ alert("test function");}function class1(){ this.property1="test property"; this.method1 = test;}function class2(){ var parent = new this.superClass(); for (p in parent){ this[p] = parent[p] }}class2.prototype.superClass=class1;var obj2 = new class2();alert(obj2.property1)obj2.method1();上面的class2从class1继承了属性property1和方法method1。 javascript is object-based, not object-oriented language. 其实flyycyu的回答不但什么都没继承下来,还是根本不能运行的,而且对prototype的使用方式也是不对的。 jqPlot 饼图上 显示气泡提示的问题 我的Jsp数据库连接 extjs中,XTemplate正则表达式的问题 怎么解决javascript小数相减会出现一长串的小数位数? 关于日期的? javascript问题 怎样取得Form中Select的属性?急 IE打印预览问题!!! 请问在php引用javascript变量,如何实现。 希望有一个简单一点的解决方法 createElement和insertRow(Cell)方法创建表格方法的对比,对比结果一定会让你大吃一惊 救命问题:如何根据单选按钮决定表单提交到哪里?
alert("test function");
}
function class1(){
this.property1="test property";
this.method1 = test;
}
function class2(){
var parent = new this.superClass();
for (p in parent){
this[p] = parent[p]
}
}
class2.prototype.superClass=class1;var obj2 = new class2();
alert(obj2.property1)
obj2.method1();上面的class2从class1继承了属性property1和方法method1。