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

最后输出的效果如下

相关推荐
山茶花开时。9 天前
[SAP] SAP MM模块学习路径
sap·mm
stone082316 天前
SAP - 使用CL_FDT_XL_SPREADSHEET将Excel文档导入到内表
sap
雨天行舟19 天前
abap调用deepseek接口 v3.0
http·ai·sap·abap·聊天·deepseek
stone082322 天前
SAP FICO程序 - 会计科目余额报表
sap
Henry-SAP22 天前
ERP(SAP) MRP 业务视角全局流程解析
人工智能·sap·软件需求·erp·sap pp
小羔羊的官方学习账号24 天前
SAP中工单控制关键配置点
sap·pp
SAP_奥维奥科技25 天前
奥维奥助力花园乳业数字化转型落地 以SAP B1破解全产业链管理难题
sap·sap管理系统·sap business one·sap管理系统软件·sap实施服务商
duangww25 天前
SAP ALV处理日元等转换因子问题
abap
sinat_3751122625 天前
ME_PROCESS_PO_CUST增强check
sap·abap·增强
Seele_10181 个月前
RAP - 报表示例
sap·abap