流星0.6.4.1变化混淆了coffeescript?

时间:2013-08-09 16:00:49

标签: coffeescript meteor

从Meteor 0.5.4升级到Meteor 0.6.4.1后,我相应地修改了我的coffeescript代码,以反映变量范围的变化。出于某种原因,我认为这些变化使coffeescript与javascript解释相混淆?

当前代码:

@liveObjects = {}
test = () ->
if liveObjects.intervalID?
  donothing;
liveObjects = {} --Maybe this is what caused the confusion? Mistaken as a local variable declaration?

从Chrome工具中我发现javascript代码为

(function() { var test;
this.liveObjects = {};

test = function() {
  var liveObjects;
  if (liveObjects.intervalID != null) {  --ReferenceError: liveObjects is not defined
    donothing;
  }
  liveOjects = {}; 

1 个答案:

答案 0 :(得分:1)

您必须再次使用此/ @设置它。

@liveObjects = {}
test = () ->
if liveObjects.intervalID?
  donothing;
@liveObjects = {}