我試圖使用Meteor.setInterval
函數,但我有一些麻煩使用它。爲什麼使用Meteor.setInterval調用方法會引發TypeError異常?
這裏是我的代碼:
Meteor.methods({
init : function(){
console.log('test');
},
start : function(period){
console.log('start : period '+period);
Meteor.setInterval(Meteor.call('init'),period);
}
});
Meteor.call('start', 100);
我看到的 「test」 我的控制檯1次,然後我得到了以下錯誤:
異常中的setInterval回調:類型錯誤:未定義不一個函數。
我一直在看這個問題:Exception in setInterval callback但我做了不同的方式(使用Method.methods
)。
發生了什麼,我該如何解決?
謝謝你這麼多的很好的解釋,現在的作品完美:) – TLR