1. 首页
  2. 考试认证
  3. 其它
  4. requirejs locate plugin使用RequireJS插件实现服务定位器模式

requirejs locate plugin使用RequireJS插件实现服务定位器模式

上传者: 2024-12-09 11:05:23上传 ZIP文件 192.13KB 热度 6次

RequireJS定位插件通过使用RequireJS插件实现服务定位器模式。这允许请求服务的语义与请求模块融合。在某种程度上,它是依赖项注入,其中依赖项通过代码即时注入,而不是通过配置声明。

用法:注册服务'registry'是一个保留的服务名称,它返回服务注册表。它有方法.register(name, service).unregister(name, service)

// Locate the registry

require([\"locate!registry\", \"oauth\"], function (registry, oauth) {

// Add some services to the registry

// The one and only authentication module registr

});

下载地址
用户评论