统一模块定义:
function UMD(name, context, definition) { if (typeof module != 'undefined' && module.exports) module.exports = definition() else if (typeof define == 'function' && define.amd) define(definition) else context[name] = definition() }
怎么用?
UMD('yourmodule',this,function(args){ //here is yourmodule code var module = ...... ...... return module; })
参考:http://www.cnblogs.com/snandy/archive/2012/03/19/2406596.html