function Aminal() {
//this指向小cat
this.eat = function () {
console.log('吃东西');
}
}
function Bird() {
this.fly = function () {
console.log('飞翔');
}
}
function Cat() {
//this指向小cat
Aminal.call(this);
Bird.call(this);
this.sayName = function () {
console.log('输出自己的名字');
}
}
let cat = new Cat();
cat.eat();
cat.fly();
js中call继承(多重继承)
最新推荐文章于 2023-07-11 09:07:07 发布