setInterval 回调中的异常 [英] Exception in setInterval callback

查看:61
本文介绍了setInterval 回调中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在调用回调函数后收到此错误:

I'm getting this error after calling a callback function like so:

function callbackInterval(test) {
   Meteor._debug("Test");
}
Meteor.setInterval(callbackInterval(test), 60000);

这是错误输出

Exception in setInterval callback: TypeError: undefined is not a function
at _.extend.withValue (packages/meteor/dynamics_nodejs.js:56)
at packages/meteor/timers.js:6
at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108)

推荐答案

如果仍然需要,或者对于那些需要它的人,正确的方法是:

If still needing, or for those who needs it, the correct way would be:

function callbackInterval(test) {
  Meteor._debug("Test");
}
Meteor.setInterval(callbackInterval, 60000);

因为测试参数会被注入到函数中,但我不知道 set Interval 是否会收到一个参数...

as the test parameter would be injected on the function, but i don't know if set Interval would receive a parameter...

这篇关于setInterval 回调中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆