我们目前正在构建一组可重复使用的应用程序。
目前我们通过使用它来工作 jQuery.sap.registerModulePath 和 jQuery.sap.require。 但根据 Using and Nesting Components您应该能够在manifest.json 文件中声明您的重用组件。
我查看了 SAPUI5 Developer Guide ,但无法真正使其发挥作用。据我所知,我需要添加以下内容:
"sap.App" :{
"embeddedBy" : "../.."
},
"sap.ui5": {
"componentUsages" :{
"<string for my reuse component>" : {
"name" : "<name of the component>"
}
"dependencies" :{
"components" : {
"<namespace of my component>"
}}
有人有一个可行的例子吗?
最佳答案
这是一个包含嵌套组件的工作示例:https://embed.plnkr.co/e7KS48/
描述符属性componentUsages
可用since 1.47.0 。定义后,UI5 负责解析组件及其模块路径 before rendering所属的 ComponentContainer。
需要 ComponentContainer,因为没有容器就无法将组件放入 UI 中。在上面的示例中,容器是在 Home.view.xml 中使用相应的 usage
属性以声明方式定义的。
<core:ComponentContainer id="containerForChildComponent"
autoPrefixId="true"
settings="{id: 'childComponent'}"
usage="reuseAnotherComponent"
manifest="true"
height="100%"
async="true"
/>
"sap.ui5": {
"componentUsages": {
"reuseAnotherComponent": {
"name": "anotherComponent",
"lazy": false
}
},
"resourceRoots": {
"anotherComponent": "./component_B"
},
// ...
}
如您所见,resourceRoots
也可以在描述符中定义,它可以指向其他组件/应用程序位置。
版本低于 1.47 的 UI5 应用示例: https://embed.plnkr.co/ytXZJ9
关于sapui5 - 在manifest.json文件中重用组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46343788/