2

我正在尝试将 htmlview(根据 SAP 的文档使用声明性支持)添加到也使用声明性支持的索引页面。使用 data-sap-ui-type="ui.MyView" 让我问两个问题:

  • 在声明性支持中是否有与 sap.ui.localResources 等效的内容?
  • data-ui-type 未将 view.html 后缀添加到应加载的视图中。在声明性支持中是否有 MVC 的特殊模式,或者目前没有办法实现它?

亲切的问候,尼科

4

1 回答 1

1

在这里找到一些基本示例: https ://openui5.hana.ondemand.com/#docs/guide/MVC.html

首先,我相信您始终必须sap.ui.localResources在代码中进行设置。

如您所见,从 HTMLView 实例化 HTMLView 如下所示:

<div data-sap-ui-type="sap.ui.core.mvc.HTMLView" id="MyHTMLView" data-view-name="example.mvc.test2"></div>

这将加载example.mvc.test2.view.html并将其放置到您的父视图中。

一般来说,JS API 会像这样转换成 HTMLView:

new sap.ui.AnyControl("myId", {
  aLittleProperty: "10",
  property: false,

  press: functionInMyController,
  morePress: a.static.myFunction,

  defaultAggregation: [ 
     new sap.ui.OtherControl("otherId1"),
     new sap.ui.OtherControl("otherId2")
  ],
  anotherAggregation: new sap.ui.OtherControl("otherId3")
}).addStyleClass("myClass");

<div data-sap-ui-type="sap.ui.AnyControl" 
     id="myId" 
     class="myClass"

     data-a-little-property="10",
     data-property="false"

     data-press="functionInMyController"
     data-more-press="a.static.myFunction">

     <div data-sap-ui-type="sap.ui.OtherControl" id="otherId1"></div>
     <div data-sap-ui-type="sap.ui.OtherControl" id="otherId2"></div>

     <div data-sap-ui-aggregation="anotherAggregation">
         <div data-sap-ui-type="sap.ui.OtherControl" id="otherId3"></div>
     </div>

</div>

注意:

  • id 和 CSS 类使用常规 HTML 属性设置
  • 属性名称从 camelCase 转换为用“-”分隔的小写(因为 HTML 不区分大小写)
  • 无论属性是什么类型,您当然都必须将其放在 HTML 中的引号中
  • 您直接放入 HTML 定义的控件中的任何内容都被视为属于它的默认聚合

克里斯

于 2014-01-23T22:11:52.153 回答