//方式一
function superClass()
{
this.name = "hi";
this.showName = function() {window.alert(this.name)};
}
function childClass()
{
}
childClass.prototype = new superClass();
var c = new childClass();
c.showName();
//方式二
var superClass = {name:"hi", showName:function() {window.alert(this.name)}};
function childClass()
{
}
childClass.prototype = superClass;
var c = new childClass();
c.showName();javascript的继承方式
最新推荐文章于 2025-12-09 14:34:24 发布
1419

被折叠的 条评论
为什么被折叠?



