加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sapui5 – 在SAP Fiori中添加自定义库作为依赖项

发布时间:2020-12-14 00:51:49 所属栏目:百科 来源:网络整理
导读:我有一个自定义库com.foo.library我想包含作为我建立的类似Fiori的应用程序的依赖项. SAP Fiori Launchpad for Developers – Launchpad应用程序的最佳实践 Declare configuration information,like the location of icons,and library dependencies in the
我有一个自定义库com.foo.library我想包含作为我建立的类似Fiori的应用程序的依赖项.

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的选项,所以我假设必须找到相对于资源的库

在您的Fiori App中:

>将您的依赖项放入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.

Source: SAP UI5 API Documentation

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读