Coffeescript Meteor 0.6.4.1的更改会混淆咖啡脚本吗?
从Meteor 0.5.4升级到Meteor 0.6.4.1后,我相应地修改了coffeescript代码,以反映变量范围的变化。出于某种原因,我认为这些更改混淆了coffeescript到javascript的解释 当前代码:Coffeescript Meteor 0.6.4.1的更改会混淆咖啡脚本吗?,coffeescript,meteor,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? M
@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 = {};
您必须再次使用此/@进行设置
@liveObjects = {}
test = () ->
if liveObjects.intervalID?
donothing;
@liveObjects = {}