function People() {
this.name = "tom";
this.age = 10;
}
People.prototype.addAge = function() {
this.age = this.age + 1;
}
function Chinese() {
People.call(this); // 继承属性
this.home = "China";
}
Chinese.prototype = new People(); // 继承方法
Chinese.prototype.getHome = function() {
return this.home;
}JS类继承
最新推荐文章于 2025-03-19 20:00:18 发布

1086

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



