
通过寻求CommonJS支持 ,这是Underscore.js库的实现方式:
编辑:对您的更新问题:
(function () { // Establish the root object, `window` in the browser, or `global` on the server. var root = this; // Create a reference to this var _ = new Object(); var isNode = false; // Export the Underscore object for **CommonJS**, with backwards-compatibility // for the old `require()` API. If we're not in CommonJS, add `_` to the // global object. if (typeof module !== 'undefined' && module.exports) { module.exports = _; root._ = _; isNode = true; } else { root._ = _; }})();这里的示例保留了Module模式。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)