js 反应/行动

反应

class Reaction {
  _page = 1;
  get page() {
    return this._page;
  }

  set page(newValue) {
    this._page = newValue;
    this.getNextPageData();
  }

  getNextPageData() {
    // ...
    console.log("curent page is: ", this.page);
    console.log("get next page data");
  }
}

const reaction = new Reaction();
reaction.page += 1;

行动

class Action {
  _page = 1;
  get page() {
    return this._page;
  }

  set page(newValue) {
    this._page = newValue;
  }

  getNextPageData() {
    // ...
    console.log("curent page is: ", this.page);
    console.log("get next page data");
  }
}

const action = new Action();
action.page += 1;
action.getNextPageData();
上一篇:PaddleHub


下一篇:比较两个实体类是否一致utils