【发布时间】:2020-08-13 08:43:43
【问题描述】:
环境
框架: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",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources",
"version": "1.38.45"
},
"description": "SAPUI5 Resources"
},
{
"path": "/webapp/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources",
"version": "1.38.45"
},
"description": "SAPUI5 Resources"
},
{
"path": "/webapp/test-resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/test-resources",
"version": "1.38.45"
},
"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 的点数:
- 应用程序“ztntapp”本身在此应用程序之外工作
- component.js 的路径是 https://webidetesting278-a392f.dispatcher.hana.ondemand.com/sap/bc/ui5_ui5/sap/ztntapp/Component.js,但是模型的路径不知何故变成了 https://webidetesting278-a392f.dispatcher.hana.ondemand.com/webapp/resources/TrackAndTrace/ztntapp/model/models.js(我不知道为什么是“webapp/resources”)
- 找到https://webidetesting278-a392f.dispatcher.hana.ondemand.com/sap/bc/ui5_ui5/sap/ztntapp/model/models.js,可能应该从这里加载资源而不是 /webapp/resources/TrackAndTrace/ 但我不知道该怎么做
其他研究
- 用neo-app.json文件,问题是定位资源 从“ztntapp”,我看到还有一个 jQuery.sap.registerResourcePath 但我不知道如何使用它 本案
【问题讨论】:
-
强烈建议升级UI5。对 1.38 的支持将在今年结束。只有这样,您才能使用当前接受的解决方案。
标签: sapui5 sap-fiori sap-cloud-platform sap-web-ide