SAP UI5 walkthrough step5 Controllers

在这个章节,我们要做的是,将之前的text文本展示为一个按钮,并将声明绑定在点击按钮事件。

因为改的是外观,所以我们修改的是view.XML

webapp/view/App.view.xml

复制代码
<mvc:View
   controllerName="ui5.walkthrough.controller.App"
   xmlns="sap.m"
   xmlns:mvc="sap.ui.core.mvc">
   <Button
      text="Say Hello"
      press=".onShowHello"/>
</mvc:View>

根据MVC架构原理,这种点击按钮事件,应该放在controller里面

所以我们这边要新建一个App.controller.js

webapp/controller/App.controller.js (New)

复制代码
sap.ui.define([
   "sap/ui/core/mvc/Controller"
], (Controller) => {
   "use strict";

   return Controller.extend("ui5.walkthrough.controller.App", {
      onShowHello() {
         // show a native JavaScript alert
         alert("Hello World");
      }
   });
});

Conventions

  • Controller names are capitalized

  • Controllers carry the same name as the related view (if there is a 1:1 relationship)

  • Event handlers are prefixed with on

  • Controller names always end with *.controller.js

最后输出的效果如下

相关推荐
sinat_375112261 天前
abap excel上传
excel·上传·sap·abap
旧巷烟火2 天前
PS成长之路⑩:如何通过WBS进行项目人工成本的精准归集
sap·ps·erp
爱喝水的鱼丶5 天前
SAP-ABAP:全面破解SAP与第三方系统集成超时难题:从应急排查到根治方案
开发语言·sap·abap·接口集成·开发交流
乐乐82345 天前
处理大数据用游标 CURSOR
abap
燚㵘䲜6 天前
CL_GUI_FRONTEND_SERVICES常用method
abap
xlxxy_10 天前
abap 批量创建供应商
运维·开发语言·sap·abap·pp·mm
淋了一场太阳雨10 天前
ABAP 使用函数获取替代(Substitution)值
sap·abap·函数·替代·subsititution
爱喝水的鱼丶12 天前
SAP-ABAP:在SAP世界里与特殊字符“斗智斗勇”:一份来自实战的避坑指南
运维·服务器·数据库·学习·sap·abap·特殊字符
淋了一场太阳雨12 天前
SAP VOFM Material determination
sap·abap
goyeer14 天前
18.[SAP ABAP] 内表(Internal Table)
sap·abap