vue項目實現定時刷新和關閉刷新功能

        <div class="refleshBtn">
          <el-button type="primary" plain size="mini" @click="recovery">恢復刷新</el-button>
          <el-button type="primary" size="mini" @click="stopReflash">停止刷新</el-button>
        </div>
  created() {
    this.timer = setInterval(() => {
      this.getList();
    }, 5000);
  },

  //銷燬前清除定時器
  beforeDestroy() {
    clearInterval(this.timer);
  },
    recovery() {
    this.timer = setInterval(() => {
      this.getList();
    }, 5000);
    },
    stopReflash() {
      clearInterval(this.timer);
    },
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章