zoukankan      html  css  js  c++  java
  • es6 class

    1定义类

     class Phone{

     construct(name,age){

    this.name=name;

    this.age=age

    }

    static hh=’丽丽‘;//static 仅仅自己使用,不能给子类使用,也不能给实例使用

    static 00=function(){//static 仅仅自己使用,不能给子类使用,也不能给实例使用

    }

    call(){//不是简写  就必须这么写

    console.log('这是自己的方法')

    }

    }

    class phone extend Phone{

    construct(name,age,q,b){

    super(name.age);

    this.q=q;

    this.d=d;

    }

    self(){

    console.log('自己的方法‘)

    }

    }

    const   pp=new phone();

    //实例可以调用父类的call方法  但是不能调用父类的同名方法(会被子类方法覆盖)

    2 get  +set方法、

    在class中

     get price(){

    console.log('获取价格0')

    }

    }

     set price(newPrice){//必须有参数

    console.log('设置价格被修改')

    }

    }

    pp.price=1000;//价格被修改

  • 相关阅读:
    2月4日进度
    每日总结3-6
    每日总结3-5
    每日总结3-4
    每日总结3-2
    本周计划
    本周计划
    假期每日总结2-13
    假期每日总结2-12
    假期每日总结2-11
  • 原文地址:https://www.cnblogs.com/fanjiawen/p/13481998.html
Copyright © 2011-2022 走看看