zl程序教程

您现在的位置是:首页 >  其他

当前栏目

js 反应&行动

ampJS 行动 反应
2023-09-14 08:58:44 时间

反应

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();