sapui5 - Error: "Cannot add direct child without default aggregation defined for control XYZ"
问题描述
I tried to find a solution by checking other questions with a similar error but none could help me. I tried to run the Component.js from my app in sandbox. Running the index.html works fine. My starting view is this:
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
controllerName="com.sap.build.standard.qrCodeScanner.controller.Home"
>
<Page id="home"
class="customHomeBackground"
showHeader="true"
title="Home"
showFooter="true"
>
<content>
<FlexBox
class="customFlexBoxHome"
justifyContent="Center"
alignItems="Center"
wrap="Wrap"
>
<GenericTile class="customTile"
header="Scan invitations"
subheader="from your customers"
frameType="OneByOne"
press="_onGenericTilePress1"
>
<TileContent>
<ImageContent src="sap-icon://bar-code"/>
</TileContent>
</GenericTile>
</FlexBox>
</content>
<footer/>
<headerContent/>
<subHeader/>
<customHeader/>
</Page>
</mvc:View>
It's simply a single GenericTile
. I can't access this view because of
Error: Cannot add direct child without default aggregation defined for control sap.m.GenericTile
Accessing the other views is no problem. So when I add e.g. a button instead of the GernericTile
+ children, it works fine.
I also tried to add one of these sample tiles instead but same error.
What's the problem with the GenericTile
?
解决方案
捎带@sunil-bn的回答:
根据提供的plunkr Sunil ,在当前版本的 UI5 中,示例代码可以正常工作。
但是,如果您像这样将库版本更改为 1.38.15 ,则会根据 OP 的问题将其损坏。
看看区别。在最新版本中,此代码有效:
<GenericTile>
<TileContent>
<ImageContent src=""/>
</TileContent>
</GenericTile>
但在旧版本中,需要相应地显式添加命名聚合:
<GenericTile>
<tileContent> <!-- named aggregation required. Default since 1.46.x -->
<TileContent>
<content> <!-- named aggregation required. Default since 1.38.18 -->
<ImageContent src=""/>
</content>
</TileContent>
</tileContent>
</GenericTile>
你需要弄清楚你使用的是什么版本的 UI5 并使用适当的 SDK 文档来构建你的应用程序,否则你会遇到麻烦。
您可以通过在 URL 中添加版本号来查看特定版本的 Demo Kit,例如https://ui5.sap.com/1.38.8/
推荐阅读
- python - 无法使用熊猫从python中的excel文件中提取元素
- linux - 即使网络消失也让 ping 继续运行
- opencart-3 - 在第 52 行的 /storage/modification/system/library/template/twig.php 中找不到类“Twig_Extension_DTwigManager”
- sha256 - 将一串数字生成的 hash-256 转换为 Java 中的 64/32 位唯一数字
- kubernetes - 列出 kubernetes 中一项服务的调用者的最佳方法是什么?
- android - 活动未自动从后台启动
- makefile - make 命令只构建第一个目标 - Makefile
- reactjs - 通过单击某个条件 Ant Design 表格展开表格的一行
- css - 尝试使用顺风容器使图像居中时遇到问题 - 图像右侧的不可见填充
- django - 如何自定义 Django 项目的管理页面?