如何解决如何重用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的点:
- 应用程序“ 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但我不确定如何将其用于 这种情况
解决方法
尝试一下:
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应用程序运行>高级设置标记首先使用我的工作区,然后按获取资源版本。在下面的列表中,您应该看到您的重用应用程序列在资源名称下:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。