0

从 Meteor 0.5.4 升级到 Meteor 0.6.4.1 后,我相应地修改了我的咖啡脚本代码以反映变量范围的变化。出于某种原因,我认为这些更改将咖啡脚本与 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 = {}; 
4

1 回答 1

1

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

@liveObjects = {}
test = () ->
if liveObjects.intervalID?
  donothing;
@liveObjects = {}
于 2013-08-09T16:11:35.233 回答