SAPUI5 路由配置中“controlAggregation”的含义是什么?

2024-02-08

我真的不明白下面的属性 controlAggregation 对于路由 SAPUI5 应用程序有何作用。 不存在具有该 id 的元素。我在此处找到的演示应用程序中的任何位置都找不到对“页面”的任何引用:SAPUI5路由演示 https://sapui5.hana.ondemand.com/#docs/guide/d9efab307ecc42b180b12cc8956e22d7.html

"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"
            }

视图定义如下 - 未提及“页面”

<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>

And

<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 是视图添加到的目标聚合。

就像在这种情况下目标是一个 sap.m.App 其 id 是app.

应用程序有一个名为的聚合pages.

详细请参见路由配置 https://sapui5.hana.ondemand.com/#docs/guide/902313063d6f45aeaa3388cc4c13c34e.html.

详细更新:

假设 controlId 是您的页面容器,容器的内容将会针对每条不同的路线而改变。

Here 容器的内容无非是app的页面聚合。

While we use routing, you just need a configuration of the routes and there targets. Let's take one example enter image description here

所以当你导航到category/{id}, sapui5 找出什么是target对于路线中的那种模式。这里是category.

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

答案是 - 它将找到该 viewName 提到的 controlAggregation(类别内部)。在这个例子中,它被称为masterPages。现在它会找到什么是controlId in the config. It is splitApp。所以最后它知道了所有需要的信息。 IE:

  1. viewName : Category ,
  2. controlId(the container of view) : splitApp
  3. controlAggregation : masterPage

现在 sapui5 将渲染Category查看里面的masterPage的聚合splitApp.

但请注意 ----** 在您的情况下,如果 controlAggegation 中未提及targets对象,在config。这意味着所有视图都有一个共同的控制聚合,即页面。

所以在这种情况下 sapui5 将在pages的聚合app.

我想你现在明白了流程。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SAPUI5 路由配置中“controlAggregation”的含义是什么? 的相关文章

随机推荐