[英]Using a SAPUI5 library in another project
我目前正在尝试了解UI5库,并且出于测试目的,使用Full-Stack-IDE中提供的模板创建了一个库项目。
根据我在各种教程中看到的内容,现在应该将应用程序部署到SCP,然后在要使用它的应用程序中声明其存在。 为此,您可以在neo-app.json中创建一个条目,如下所示:
"routes": [
...,
{
"path": "/resources/my/custom",
"target": {
"type": "application",
"name": "testlibrary",
"entryPath": "/"
},
"description": "Utility library"
}
]
并在manifest.json中像这样:
"dependencies": {
"libs": {
...,
"my.custom.testlibrary": {}
}
},
但是,当我这样做时,我的应用程序尝试在以下URL下查找该库: https : //openui5.hana.ondemand.com/1.52.5/resources/,而不是在我部署该应用程序的SCP上。 我的neo-app.json条目和manifest.json条目之间似乎没有链接。 我在这里做错了什么?
您可以通过右键单击您的项目,然后选择Project> Add Reference to Library来添加定制库。 然后选择SAP Cloud Platform作为存储库,并包含您的库。
neo-app.json
route
的结果path
为/webapp/resources/my/custom
neo-app.json
这是在SAP Web IDE中运行本地预览所必需的。 在将消费者应用程序部署到SAP Cloud Platform时,作为构建过程的一部分,该路由将被重写为排除webapp
,即路径将为/resources/my/custom
,以便在部署时也将正确重定向。 这对我来说使用"@sap/grunt-sapui5-bestpractice-build": "1.3.64"
来为我工作。
使用上面的方法,您不需要在消费者应用程序的index.html
每个库添加data-sap-ui-resourceroots
条目。
在ui5help Slack频道中找到了答案。 问题是我的库需要在resourceroots下的index.html中声明。 像这样更改我的neo-app.json:
"routes": [
...,
{
"path": "/webapp/resources/my/custom",
"target": {
"type": "application",
"name": "testlibrary",
"entryPath": "/"
},
"description": "Utility library"
}
]
并将其添加到我的index.html中:
data-sap-ui-resourceroots='{
"docgen": "./",
"my.custom.testlibrary": "./resources/my/custom"
}'
解决了问题。 我将继续尝试看看是否必须为每个库执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.