Skip to content

Instantly share code, notes, and snippets.

@regou
Last active August 29, 2015 13:57
Show Gist options
  • Save regou/9504368 to your computer and use it in GitHub Desktop.
Save regou/9504368 to your computer and use it in GitHub Desktop.
通用模块写法
(function(window, module, define) {
'use strict';
var context=function(require){
//edit here
return moduleOnto;
};
if(module){module.exports=context(require);}else if(define){define(context);}else{ window.moduleOnto=context();}
})(typeof window !== "undefined" ? window : {}, typeof module !== "undefined" && module.exports? module:null, typeof define === 'function'?define:null );
@regou
Copy link
Author

regou commented Mar 18, 2014

兼容 nodejs seajs Browserify RequireJS 和 script标签;

script标签下不支持内部require模块。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment