写一个插件,兼容commonjs,amd,cmd,原生js。
;(function (global, factory) {
if(typeof define == 'function' && define.amd){
define([], factory);//amd
}else if(typeof module === 'object' && typeof module.exports == 'object'){
module.exports = factory();//commonjs
}else{
global.myJsPlugin = factory();
}
})(this, (function () {
const myJsPlugin = {
//在这里定义对象的属性和方法
};
return myJsPlugin;
}))