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

最后输出的效果如下

相关推荐
爱喝水的鱼丶22 天前
SAP-ABAP:SAP外网接口调用技术全景指南
运维·http·sap·abap·erp·接口调用·开发运维
ABAP 成23 天前
SAP的WPS导出找不到路径怎么办;上载报错怎么办
abap
爱喝水的鱼丶24 天前
SAP -ABAP:SAP 业务能力培养体系(结构化学习路径)
运维·开发语言·sap·abap·erp·业务学习
爱喝水的鱼丶1 个月前
SAP-ABAP:SAP数据库视图(Database View)详解-创建
sap·abap·erp·企业级应用·经验交流
聆听-往昔2 个月前
SAP Webide系列(7)- 优化FreeStyle新建项目预设模板
前端·sap·开发工具·fiori·sap ui5·webide
izumisrcd2 个月前
Fiori APP配置中的Semantic object 小bug
sap
爱喝水的鱼丶2 个月前
SAP-ABAP:SAP中REPORT程序和online程序的区别对比
sap·abap·erp·企业应用·开发运维
数字化转型20252 个月前
SAP CO End-User Training Material Document Agenda
sap
SAP学习成长之路2 个月前
了解 ALV 中的 field catalog (ABAP List Viewer)
开发语言·sap·abap
天边浮云2 个月前
ABAP 获取用户参数文件
经验分享·sap