【发布时间】:2010-09-18 19:28:23
【问题描述】:
为什么子类没有 echo() 方法?
Parent = function(){
this.name = 'abc';
}
Parent.prototype.echo = function(){
alert(this.name);
}
Child = function(){
$.extend(this, Parent);
}
var x = new Child();
x.echo();
如何在Javascript中继承父类?
【问题讨论】:
-
这是使用 jQuery 吗? 'plain' javascript 中的子类化不能以这种方式工作。
-
把 jQuery
$.extend扔进去只会把一切搞得一团糟。
标签: javascript class inheritance