vue 定时器(定时任务)

vue 页面定时向后端发送请求进行数据刷新 

  mounted() {
            //定时器
            const timer = setInterval(() => {
                this.initdata();//你所加载数据的方法
    
    }, 5000)
           //销毁定时器
              this.$once('hook:beforeDestroy', () => {
            clearInterval(timer)
         })
}

 

posted @ 2020-12-02 11:37  飞力飞思  阅读(10208)  评论(0编辑  收藏  举报