ES6 class 继承
class Phone {
constructor(brand, price) {
this.brand = brand
this,price = price
}
call () {
console.log('我可以打电话')
}
}
class SmartPhone extends Phone {
constructor (brand, price, color, size) {
super(brand, price)
this.color = color
this.size = size
}
photo () {
console.log('我可以拍照')
}
playGame () {
console.log('我可以玩游戏')
}
call () {
console.log('我可以视频通话')
}
}
let xiaomi = new SmartPhone('小米', 7999, '黑色', '5.1')
xiaomi.call()
xiaomi.photo()
xiaomi.playGame()
浙公网安备 33010602011771号