data :{
timer:null
}
//在onshow里添加定时器
onShow() {
let _this = this;
this.setData({
timer: setInterval(() => {
_this.getApi(); // 这个是我要实时刷新的事件
}, 5000)
})
},
点击左上角返回按钮会触发onUnload事件
onUnload(){
clearInterval(this.data.timer);
this.setData({
timer: null
})
},