// static 标注的属于类不属于实例
class Phone {
constructor(name, price) {
this.name = name;
this.price = price
}
stop(){
console.log('执行暂停')
}
}
class amartPhone extends Phone {
constructor(name, price,color,size) {
super(name, price);
this.name = name;
this.price = price
this.color = color
this.size = size
}
play(){
console.log('执行播放')
}
stop(){
console.log('执行暂停222')
}
}
const amar = new amartPhone('小木', '240','黑色','50*100')
console.log(amar);
amar.stop()
amar.play()
es6-class 类继承(子类对父类的重写)
最新推荐文章于 2023-04-23 11:58:44 发布