SAP UI5 中的聚合 [英] Aggregation in SAP UI5

查看:29
本文介绍了SAP UI5 中的聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释一下 SAP UI5 中聚合的确切含义?我正在尝试制作一个具有两个视图的应用程序,我想从一个视图导航到另一个视图,反之亦然.所以,APP控件有聚合,所以我很困惑聚合是什么?

Can anybody explain what exactly Aggregation means in SAP UI5 ? I am trying to make an app with two views and i want to navigate from one view to another and vice -versa. So , the APP control is having aggregation , so i am confused what Aggregation is ?

推荐答案

词汇表:

聚合(在 UI5 上下文中)是两种 UI 元素类型之间的特殊关系.它用于定义父子关系 [...].聚合的父端具有 基数 0..1,而子端可能有 0..10..*.

An aggregation (in the context of UI5) is a special relation between two UI element types. It is used to define the parent-child relationship [...]. The parent end of the aggregation has cardinality 0..1, while the child end may have 0..1 or 0..*.

例如,列表 可能有 0 个或多个项目.一个项目有 0 或 1 个列表作为其父项.因此,该列表具有聚合 «items».

For example, a list may have 0 or many items. An item has 0 or 1 list as its parent. Therefore, the list has an aggregation of «items».

在我们的例子中,控制 sap.m.App,它是从 sap.m.NavContainer,有一个名为 «pages» 的默认聚合,我们可以在其中定义任何扩展的集合sap.ui.core.Control 作为其子控件.

In our case, the control sap.m.App, which is extended from sap.m.NavContainer, has a default aggregation named «pages» where we can define a collection of anything extended from sap.ui.core.Control as its child controls.

页面:sap.ui.core.Control [ ]

pages: sap.ui.core.Control [ ]

但只是将视图手动添加到 是一种反模式,因为视图通常具有 Page 在其中,单个页面占据了 100% 的高度,从而将其他视图推开.除此之外,它使实现导航变得更加困难.

But just adding the views manually into <pages></pages> is an anti-pattern since a view has usually a Page in it and a single page takes up 100% of the height which pushes other views away. Besides that, it makes implementing navigation much more difficult.

相反,当前的最佳做法是使用所谓的«路由器» 通常在应用程序描述符 (manifest.json) 中与其他导航属性一起定义.它的姐妹控件 Target 负责 将导航视图添加到 «pages» 聚合.要了解如何使用路由器实现导航,请查看以下资源:

Instead, the current best practice is to use a so-called «router» which is usually defined in the application descriptor (manifest.json) with other navigation properties. Its sister control Target takes care of adding the navigated view to the «pages» aggregation. To find out how to achieve navigation using a router, take a look at these resources:

  • Examples: Basic navigation, navigation inside a static parent control
  • «Routing and Navigation» from Walkthrough (see also further steps)
  • «Routing and Navigation» from Essentials to understand the basic concepts.

这篇关于SAP UI5 中的聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆