一、前言
一般会遇到需要页面进行定时刷新的功能,当做看板来使用。
二、实现
// 页面初始化调用数据更新的方法
created() {
// 获取数据
this.getData();
// 定时更新数据
this.refresh();
},
// 在数据更新方法里面通过延时器调用数据获取的方法
// 用于定期刷新
// this.getData();获取数据
refresh() {
this.timerId = setTimeout(() => {
this.getData();
this.refresh();
}, 1 * 60 * 1000);
},