SAP Fiori Launchpad for Developers – > Launchpad应用程序的最佳实践
Declare configuration information,like the location of icons,and library dependencies in the component.js configuration file
有道理,将我的库添加为依赖项看起来像
dependencies: { libs: ["sap.m","sap.ui.layout","com.foo.library"],components: [] },
与Fiori一样,您必须使用相对路径.
例如,为了我依赖工作,必须找到它
/resources/com/foo/library
将自定义库上载到ABAP SAPUI5存储库并使其具有相对路径的步骤有哪些?
编辑:
目前我在Component.init上加载了库
sap.ui.getCore().loadLibrary("com.foo.library","absolute path to library");
它工作,但我想将库设置为依赖
ComponentMetadata.prototype._loadDependencies = function() { .. if (aLibraries) { jQuery.each(aLibraries,function(i,sLib) { jQuery.sap.log.info("Component \"" + that.getName() + sap.ui.getCore().loadLibrary(sLib); }); }
从上面的代码我可以看到当组件加载库依赖项时没有传递url的选项,所以我假设必须找到相对于资源的库
>将您的依赖项放入app描述符(manifest.json)(或者如果在Component.js中的配置中没有使用app描述符)
dependencies: { libs: ["sap.m",components: [com.foo.component] }
>让sap.ui.core知道在哪里搜索库的命名空间.(Component.js的顶部)
jQuery.sap.registerModulePath("com.foo","/Path/on/the/server/");
现在您可以使用您的依赖项了.这就是为什么:
Before a module is loaded,the longest registered prefix of its module
name is searched for and the associated URL prefix is used as a prefix
for the request URL. The remainder of the module name is attached to
the request URL by replacing dots (‘.’) with slashes (‘/’).The registration and search operates on full name segments only.