delayTime: 1000,
test1 = 0,
.
.
.
.
.
.
.
.
testTime(){
const _this = this
function foo() {
console.log(new Date());
_this.test1 = _this.test1 + 1;
console.log(_this.test1);
_this.timer = setTimeout(foo, _this.delayTime);
if (_this.test1 == 30) {
//符合条件 删除定时器
console.log("停止");
clearTimeout(_this.timer);
}
}
foo();
}