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>
相关推荐
恋猫de小郭7 分钟前
Shopify 从 React Native 回到 Swift/Kotlin,但是你以为有手就行??
android·前端·ios
BillKu43 分钟前
Element Plus 的 el-tab-pane:lazy 的说明
前端·javascript·vue.js
爱勇宝1 小时前
《道德经》第 11 章:真正有用的,常常是你没写出来的那部分
前端·后端·产品
jearry1 小时前
WebView2 原生拖放的桥接之道:拆解 yyzTools 的 drop-zone.js
前端·c++
一位正在转型AI全栈的前端工程师1 小时前
AI 全栈学习之旅 -Week 11:从 CLI 到浏览器:用 FastAPI、SSE 和 Vue 3 做一个可审核的 ReAct Agent
前端·python
10share1 小时前
我为什么用 React 重写了一个 VitePress
前端·react.js
计算机魔术师1 小时前
GPT-6 Astra 发布后,Sebastian Raschka 解析 looped transformer 与隐藏推理链传闻
前端
不可能片场1 小时前
Electron 退化成 node:一个环境变量的锅
前端·electron
楚楚河河1 小时前
js 变量声明
前端
Cicada1281 小时前
Web 服务器怎么选
运维·服务器·前端