Commit cec29d63 authored by 范雪寒's avatar 范雪寒

fix: timeout

parent fa80041d
...@@ -94,6 +94,8 @@ cc.Class({ ...@@ -94,6 +94,8 @@ cc.Class({
}, },
// 生命周期 onLoad // 生命周期 onLoad
onLoad() { onLoad() {
this._timeoutIds = [];
this._intervalIds = [];
this.initSceneData(); this.initSceneData();
this.initSize(); this.initSize();
window.ccc = this; window.ccc = this;
...@@ -221,6 +223,7 @@ cc.Class({ ...@@ -221,6 +223,7 @@ cc.Class({
callback('WRONG') callback('WRONG')
} }
}, 1000); }, 1000);
this._timeoutIds.push(id);
// Perform cleanup // Perform cleanup
return () => clearInterval(id); return () => clearInterval(id);
...@@ -789,6 +792,17 @@ cc.Class({ ...@@ -789,6 +792,17 @@ cc.Class({
_timeoutIds: null,
_intervalIds: null,
// 生命周期
onDestroy() {
this._timeoutIds.forEach(id => {
clearTimeout(id);
});
this._intervalIds.forEach(id => {
clearInterval(id);
});
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment