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

最后输出的效果如下

相关推荐
SAP_奥维奥科技16 小时前
化工企业SAP ERP怎么选?从第一次没做成,到连续做到第八期
sap
Henry-SAP4 天前
具身智能新突破:开源生态与IPO热潮
人工智能·云原生·sap·erp
Henry-SAP6 天前
SAP引领ERP智能化转型
人工智能·云原生·sap·erp
爱喝水的鱼丶7 天前
SAP-ABAP:BAPI 基础认知:SAP 标准业务对象接口的核心逻辑与调用入门
信息可视化·性能优化·sap·abap·bapi·开发交流·交流学习
Henry-SAP8 天前
SAP S/4HANA引领物流ERP新生态
人工智能·云原生·sap·erp
rm -rf * && haha.sh8 天前
【ABAP】SUBMIT 用法详解
sap·abap·abap开发
爱喝水的鱼丶10 天前
SAP-ABAP:性能优化效果验证与回归测试:优化前后性能对比、业务逻辑兼容性校验方案
性能优化·sap·abap·回归测试·开发交流·交流学习
Henry-SAP10 天前
SAP MRP类型如何影响计划订单生成
人工智能·云原生·sap·erp
爱喝水的鱼丶10 天前
SAP-ABAP:接口与报表场景专项优化:RFC/ODATA 接口、ALV 报表的性能提升方案
运维·性能优化·接口·sap·abap·rfc·经验交流
爱喝水的鱼丶15 天前
SAP-ABAP:SAP性能分析核心工具入门——ST05/SAT/ST12等常用事务码的基础用法解析
性能优化·sap·abap·性能分析·开发交流·交流学习