模块增强与克隆技术详解
1. 模块增强技术
1.1 紧密增强模块示例
在 JavaScript 开发中,模块增强是一项重要的技术,它能帮助我们在不修改原有模块核心代码的基础上,对模块进行功能扩展。下面是一个紧密增强模块的示例代码:
(function(coreModule){
if(!coreModule){
ImagesInc_LoggingHandler.logError('coreModule was not found to be augmented!');
alert('coreModule was not found to be augmented!');
return false;
}
coreModule.original_someText = coreModule.someText;
coreModule.someText = "this is a test for overriding module properties with TIGHT augmentation!";
coreModule.getExtendedModuleMsg = function(){
ImagesInc_LoggingHandler.logInfo(coreModule.someText);
};
coreModule.getExtendedModuleOriginalMsg = function(){
ImagesInc_LoggingHandler.logIn
超级会员免费看
订阅专栏 解锁全文
1749

被折叠的 条评论
为什么被折叠?



