Javascript UMD样式子模块
是否可以以UMD风格的方式单独创建子模块?假设我有这个:Javascript UMD样式子模块,javascript,umd,Javascript,Umd,是否可以以UMD风格的方式单独创建子模块?假设我有这个: (函数(根,工厂){ if(typeof define==='function'&&define.amd){ 定义([],工厂(根)); }else if(导出的类型==='object'){ module.exports=工厂(根); }否则{ root.thing=工厂(root); } })(typeof global!=“未定义”?全局:this.window | | this.global,函数(根){ "严格使用",; //
(函数(根,工厂){
if(typeof define==='function'&&define.amd){
定义([],工厂(根));
}else if(导出的类型==='object'){
module.exports=工厂(根);
}否则{
root.thing=工厂(root);
}
})(typeof global!=“未定义”?全局:this.window | | this.global,函数(根){
"严格使用",;
//公共API的对象
var thing={};
thing.add=函数(数字){
返回号码+2;
};
归还物;
});代码>