如何重用UI5 1.38中另一个应用程序的组件?

问题描述

环境

框架:SAPUI5 V1.38.39
IDE:SAP WEB IDE

问题

我想在另一个应用程序中使用一个SAPUI5应用程序,为此,我找到了以下资源:https://blogs.sap.com/2017/04/05/sapui5-how-to-reuse-parts-of-a-sapui5-application-in-othermultiple-sapui5-applications/

我想在其中重复使用另一个应用程序中的代码

在我使用的init的component.js中:

var sPath = sHostUrl.includes("webidetesting") ? "https://gtyext.net" : sHostUrl;
jQuery.sap.registerModulePath("ztntapp",`${sPath}/sap/bc/ui5_ui5/sap/ztntapp/`);

在我看来:

<core:ComponentContainer 
    name="ztntapp" 
    manifestFirst="true" 
    component="ztntapp">
</core:ComponentContainer>

和neo-app.json

{
    "path": "/sap/bc/ui5_ui5/sap/ztntapp/","target": {
        "type": "destination","name": "gtyext_net","entryPath": "/sap/bc/ui5_ui5/sap/ztntapp/"
    },"description": "namespace.tntapp Resources"
}

重复使用的应用中的代码

在component.js中

sap.ui.define([
    "sap/ui/core/UIComponent","sap/ui/Device","./model/models"
],function (UIComponent,Device,models) {
    "use strict";

    return UIComponent.extend("TrackAndTrace.ztntapp.Component",{

        metadata: {
            manifest: "json"
        },init: function () {
        [...]
        },[...]
   });
});

在neo-app.json中(这是通过SAP WebIDE创建的默认设置):

{
  "welcomeFile": "/webapp/index.html","routes": [
    {
      "path": "/resources","target": {
        "type": "service","name": "sapui5","entryPath": "/resources","version": "1.38.45"
      },"description": "SAPUI5 Resources"
    },{
      "path": "/test-resources","entryPath": "/test-resources",{
      "path": "/webapp/resources",{
      "path": "/webapp/test-resources","description": "SAPUI5 Test Resources"
    }
  ],"sendWelcomeFileRedirect": true
}

错误消息

未捕获的错误:无法从加载“ ztntapp / Component.js” https://webidetesting278-a392f.dispatcher.hana.ondemand.com/sap/bc/ui5_ui5/sap/ztntapp/Component.js: 错误:无法从中加载“ TrackAndTrace / ztntapp / model / models.js” 资源/TrackAndTrace/ztntapp/model/models.js

带有neo-app.json的点:

其他研究

  • 使用neo-app.json文件,问题在于找到资源 从“ ztntapp”中,我看到还有一个 jQuery.sap.registerResourcePath但我不确定如何将其用于 这种情况

解决方法

尝试一下:

jQuery.sap.registerModulePath(“ ztntapp”,“ / sap / bc / ui5_ui5 / sap / ztntapp”)

而不是 jQuery.sap.registerModulePath(“ ztntapp”,${sPath}/sap/bc/ui5_ui5/sap/ztntapp/

也请检查此链接: https://answers.sap.com/questions/668485/ui5-failed-to-load-componentjs-while-using-compone.html

,

在第一个应用程序(主应用程序)中,请使用manifest.json添加组件用法,而不要在Component.js中添加jQuery.sap.registerModulePath

"componentUsages": {
    "ztntapp": {
            "name": " TrackAndTrace.ztntapp","settings": {},"componentData": {},"lazy": true
    }
}

然后,您需要调整主应用程序neo-app.json以启用运行配置进入第二个应用程序(重用应用程序)

"routes": [
        {
      "path": "/webapp/resources/TrackAndTrace/ztntapp","target": {
        "type": "application","name": "ztntapp"
      }
    },{
      "path": "/resources/TrackAndTrace/ztntapp",

然后针对Resue应用程序:部署您的应用程序,使其在SAP WebIDE Fullstack工作区中注册。

然后在WebIDE中为您的主应用程序选择运行>运行配置>添加配置>以Web应用程序运行>高级设置标记首先使用我的工作区,然后按获取资源版本。在下面的列表中,您应该看到您的重用应用程序列在资源名称下: WebIDE Config

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...