标准插件写法

 1 (function(){
 2   var moduleName = function(){
 3     //dosomething
 4   };
 5     if (typeof module !== 'undefined' && typeof module.exports === 'object') {
 6         module.exports = moduleName;
 7     } else if (typeof define === 'function' && (define.amd || define.cmd)) {
 8         define(function() { return moduleName; });
 9     } else {
10         this.moduleName = moduleName;
11     }
12 }).call( this || (typeof window !== 'undefined' ? window : global));//this可能为null

 

posted @ 2017-04-19 11:53  术虫  阅读(383)  评论(0编辑  收藏  举报