constructor()方法

const custommetaCondition = new Rest(A, B)

export default class Rest {
  /**
   * 构造函数
   * @param {String} subSys 子系统英文名(小写)
   * @param {String} module 模块英文名(小写)
   */
  constructor (subSys, module) {
    this.subSys = subSys
    this.module = module
  }
}

ES6 提供的更接近传统语言的写法,引入 Class(类)概念,作为对象的模板。

constructor方法,类的构造方法,实例化这个类就调用这个方法,this代表实例的对象。

实例化Rest时类里面的参数进入实例中。

posted @ 2022-12-06 22:19  轻风细雨_林木木  阅读(17)  评论(0编辑  收藏  举报