class继承

xml 复制代码
<script>
    class Point {
       constructor(x, y) {
          this.x = x
          this.y = y
       }
       say() {
          console.log("我父类方法");
       }
    }
    class ColorPoint extends Point {
       //子类继承父类,必须实现构造函数
       constructor(x,y,z){
          super(x,y)
          this.z = z  
       }
       hi(){
          super.say()//调用父类方法
       }
    }
    const p = new ColorPoint(10,20)
    p.hi()
    // console.log(p.x);
</script>
相关推荐
sunny_43 分钟前
构建工具的第三次革命:从 Rollup 到 Rust Bundler,我是如何设计 robuild 的
前端·rust·前端工程化
rfidunion2 小时前
springboot+VUE+部署(12。Nginx和前端配置遇到的问题)
前端·vue.js·spring boot
珹洺2 小时前
Java-servlet(五)手把手教你利用Servlet配置HTML请求与相应
java·运维·服务器·前端·servlet·html·maven
FYKJ_20102 小时前
springboot大学校园论坛管理系统--附源码42669
java·javascript·spring boot·python·spark·django·php
QQ24391972 小时前
语言在线考试与学习交流网页平台信息管理系统源码-SpringBoot后端+Vue前端+MySQL【可直接运行】
前端·spring boot·sql·学习·java-ee
范特西.i3 小时前
QT聊天项目(6)
前端
a1117763 小时前
水体渲染系统(html开源)
前端·开源·threejs·水体渲染
程序员小李白3 小时前
CSS 盒子模型
前端·css·html
Zzz不能停3 小时前
单行 / 多行文本显示省略号(CSS 实现)
前端·css
xiaoxue..3 小时前
TailwindCSS:从“样式民工”到“UI乐高大师”的逆袭
前端·css·ui