gpt4 book ai didi

sapui5 - SAPUI5路由配置中 'controlAggregation'是什么意思?

转载 作者:数据小太阳 更新时间:2023-10-29 05:11:53 26 4
gpt4 key购买 nike

我真的不明白下面的属性 controlAggregation 对路由 SAPUI5 应用程序有何作用。没有具有该 ID 的元素。我在此处找到的演示应用程序中的任何地方都找不到对“页面”的任何引用:SAPUI5 routing demo

"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"viewPath": "sap.ui.demo.nav.view",
"controlId": "app",
"controlAggregation": "pages", // what does this do?
"transition": "slide",
"bypassed": {
"target": "notFound"
}

View 定义如下 - 没有提及“页面”

<mvc:View
controllerName="sap.ui.demo.nav.controller.App"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true">
<App id="app"/>
</mvc:View>

<mvc:View
controllerName="sap.ui.demo.nav.controller.Home"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<Page title="{i18n>homePageTitle}" class="sapUiResponsiveContentPadding">
<content>
<Button id="displayNotFoundBtn" text="{i18n>DisplayNotFound}" press="onDisplayNotFound" class="sapUiTinyMarginEnd"/>
</content>
</Page>
</mvc:View>

最佳答案

controlAggregation 是添加 View 的目标聚合。

在这种情况下,target 是一个 sap.m.App,它的 id 是 app

应用有一个名为页面的聚合。

有关详细信息,请参阅 routing configuration .

UPDATED IN DETAIL:

假设 controlId 是您的页面容器,容器的内容 将针对每个不同的路由进行更改。

这里容器的内容只不过是应用程序的页面聚合。

虽然我们使用路由,但您只需要配置路由和目标。让我们举一个例子 enter image description here

因此,当您 navigateTo category/{id} 时,sapui5 会找出路径中该模式的目标。这是类别

接下来,它会在 targets 对象中找到此目标(这里是类别)的 viewName(请参阅在路由数组之后有一个包含类别、产品的目标对象。 ..).所以 SapUI5 获得了要渲染的 View 。但是在哪里渲染这个 View 呢?

答案是 - 它会找到针对该 View 名称提到的 controlAggregation(类别内)。在这个例子中,它被称为 masterPages。现在它会在 config 中找到什么是 controlId。它是 splitApp。所以最后它知道了所有需要的信息。即:

  1. viewName : 类别 ,
  2. controlId( View 的容器) : splitApp
  3. controlAggregation : masterPage

现在 sapui5 将在 splitAppmasterPage 聚合中呈现 Category View 。

但请注意 ----** 在您的情况下,如果 targets 对象中未提及 controlAggegation,它会在 config 中提及。这意味着对于所有 View ,都有一个公共(public)的 controlAggregation,即页面。

所以在这种情况下,sapui5 将在 apppages 聚合中呈现您的 View 。

我想你现在明白流程了。

关于sapui5 - SAPUI5路由配置中 'controlAggregation'是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38616923/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com