使用setInterval报错

发布于 7 年前作者 jie033224 次浏览最后编辑 7 年前来自 ask

我在Page内部定义了一个test方法,然后在Onload方法里使用

setInterval(that.test(), 10000);

小程序就报错了

错误信息:

setInterval expects a function as first argument but got undefined.;at pages/index/index page lifeCycleMethod onLoad function

TypeError: setInterval expects a function as first argument but got undefined.

1 回复
bli
bli1 楼5 年前

你把this.test()的括号去掉就可以了