new newTimer(interval, callback)
计时器
参数(Parameters):
名称 | 类型 | 描述 |
---|---|---|
interval |
number | 时间间隔(单位:秒) |
callback |
function | 回调函数 |
示例(Example)
// 初始化一个计时器
var timer = x.newTimer(5, function(timer) {
console.log(new Date());
// 启动计时器
timer.stop();
});
// 停止计时器
timer.start();
方法(Methods)
-
start()
-
启动计时器
-
stop()
-
停止计时器