以下是Ts代码:
'''
let Index = 100;
this.mIndex = 0;
let funUp = function () {
this.mIndex ++;
// 等于 100 的时候停止计时器回调
if (Index <= this.mIndex) {
this.unschedule(funUp);
}
}
this.schedule(funUp, newTime);
'''
schedule : 定时器开始
unschedule : 停止定时器
条件: 这个必须写在一个组件的实体类中
最后标注一下,停止循环 unschedule 传的参数是回调函数,这个很奇特.