vue的页面销毁,但是倒计时依旧继续的问题处理

  data () {
    return {
      timer : null
    }
  },
  beforeDestroy () {
    let that = this;
    clearInterval(that.timer);
    that.timer = null;
  },
  destroyed () {
    let that = this;
    clearInterval(that.timer);
    that.timer = null;
  },
  mounted () {
    let that = this;
    that.timer = window.setInterval(() => {
      setTimeout(() => {
        that.getData()
      }, 0)
    },1000)
  },

  

posted @ 2021-08-04 17:14  全村最靓的程序猿  阅读(465)  评论(0编辑  收藏  举报