首页 > 其他分享 >class的类继承

class的类继承

时间:2023-02-26 10:04:51浏览次数:26  
标签:console log 继承 price class brand size

 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script>
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("玩游戏");
// }
}

const xiaomi = new SmartPhone('小米',799,'黑色','4.7inch')
console.log(xiaomi);
</script>
</body>
</html>

 

 

class的类继承_父类

 



标签:console,log,继承,price,class,brand,size
From: https://blog.51cto.com/u_15687135/6086006

相关文章

  • class的静态成员
     <script>//ES5//手机类//functionPhone(brand,price){//this.brand=brand;//this.price=price;//}//Phone.phoneName='......
  • ES5构造函数继承
      <!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title></head><body><script>functionPhone(brand,pr......
  • class介绍初体验
     <!DOCTYPEhtml><html><head><metacharset="utf-8"><title></title></head><body><script>classShouji{......
  • 继承权限
    类的继承的权限有三种:私有,保护和公有从访问对象的角度来说一共包含三类访问对象:类的实例友元函数和友元类类的成员函数针对这三种访问对象我们较为清晰分出继承的访......
  • 方法继承的真相---虚方法表
    虚方法表方法重写的本质我们关注一个类往往会把注意点放在它的成员变量上,而对于他的成员方法往往关注的比较少。在类的继承中我们知道成员方法往往都会被继承,但是对于......
  • classification_report()评估报告
    1、使用数据生成器后获得标签映射方法一:labels=[kforkintrain_generator.class_indices]方法二:1labels=[None]*len(test_generator.class_indices)2fo......
  • The bean ‘api‘, defined in class path resource [com/common/swagger/SwaggerAuto
    Thebean‘api‘,definedinclasspathresource[com/common/swagger/SwaggerAutoConf1.解决办法-1将重复的bean覆盖掉加一个这个注解spring.main.allow-bean-definit......
  • Lightroom Classic for mac(Lrc2021) v10.4 激活版
    Lightroom Classic2021mac中文版是一款以后期制作为重点的图形工具软件,其增强的校正工具、强大的组织功能以及灵活的打印选项可以帮助您加快图片后期处理速度,将更多的时......
  • [经验] 农转非的城市公民继承农村宅基地问题
    1概述1.1基础术语:宅基地宅基地是农村村民用于建造住宅及其附属设施的集体建设用地,包括住房、附属用房和庭院等用地,在地类管理上属于(集体)建设用地。1.1.1《民法典》......
  • c++中具有继承关系的隐式转换问题
    起因是群里有人问:   2,3,4是为什么。解答:2:2是因为B中的show(A)才是多态,Aa2=newB(),此时a2只有show(A)的多态,而面对的类型切割问题,在编译的时候派生类会将基类的多......