且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-12-13 11:26:44

在您的 Fiori 应用程序中:

In your Fiori App:

  1. 将您的依赖项放入应用程序描述符 (manifest.json)(或者如果没有在 Component.js 中的配置中使用应用程序描述符)

  1. Put your dependencie into the app descriptor (manifest.json) (or if no app descriptor used into the config inside the Component.js)

dependencies: {
    libs: ["sap.m", "sap.ui.layout", "com.foo.library"],
    components: [com.foo.component]
}

  • 让 sap.ui.core 知道在哪里搜索你的库的命名空间.(你的 Component.js 的顶部)

  • Let sap.ui.core know where to search for the namespace of your library.(Top of your Component.js)

    jQuery.sap.registerModulePath("com.foo", "/Path/on/the/server/");
    

  • 现在您可以使用您的依赖项了.原因如下:

    And now you can use your dependencies. And here is why:

    在加载模块之前,其模块的最长注册前缀搜索名称并将关联的 URL 前缀用作前缀对于请求 URL.模块名称的其余部分附加到通过用斜杠 ('/') 替换点 ('.') 来获取请求 URL.

    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.

    来源:SAP UI5 API 文档一个>