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();
posted @ 2020-01-11 15:54  Ajanuw  阅读(190)  评论(0编辑  收藏  举报