vue页面实现简单的定时刷新
export default {
data() {
return {
};
},
mounted: function () {
loadRemote(this);//最开始默认加载的数据,自己定义的方法
if(this.timer){
clearInterval(this.timer);
} else{
this.timer = setInterval(() => {
loadRemote(this);//再次加载数据,自己定义的方法
console.log("成功了");
}, 10000);//每隔十秒刷新一次
}
},
destroyed() {//页面关闭时调用
clearInterval(this.timer)
},
methods: {}
};
//加载数据,自己定义的方法
function loadRemote(state) {}
还没有评论,来说两句吧...