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;//价格被修改

  • 相关阅读:
    nginx特性
    mysql增删改查
    keepalived+nginx集群
    nginx+tomcat集群方法
    jdk环境配置(Windows)
    nginx_http核心模块(二)
    nginx入门手册(一)
    nginx 配置文件解析(一)
    tcpdump用法
    Tcpdump.
  • 原文地址:https://www.cnblogs.com/fanjiawen/p/13481998.html
Copyright © 2011-2022 走看看