一般的插件封装
;(function (global) { "use strict"; function MyPlugin(el, options) { //some cod }; MyPlugin.prototype = { //定义方法 show: function () { //some pre } }; if (typeof module !== 'undefined' && module.exports) { //兼容CommonJs规范 module.exports = MyPlugin; } else if (typeof define === 'function') { //兼容AMD/CMD规范 define(function () { return MyPlugin }) } else { //注册全局变量,兼容直接使用script标签引入插件 global.MyPlugin = MyPlugin; }})(this);


