有人可以解释什么是出口变量:
从backbone.js复制,我也注意到spine.js使用相同的模式.
https://gist.github.com/1375748
var Backbone; if (typeof exports !== 'undefined') { Backbone = exports; } else { Backbone = root.Backbone = {}; }
解决方法
该模块模式是
CommonJS规范中称为
CommonJS Modules的一部分:
In a module,there is a free variable called “exports”,that is an
object that the module may add its API to as it executes.
所以基本上添加到exports对象定义了模块公开的API.