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

最后输出的效果如下

相关推荐
EasyStudios2 天前
金色传说:SAP-ABAP-Excel数据导入工具函数示例
sap·abap·excel导入
EasyStudios2 天前
金色传说:SAP-ABAP-交货单创建及过账工具类示例
sap·abap·工具类·se24·交货单bapi
goyeer5 天前
05.[SAP ABAP] ABAP中的运算符
算法·sap·abap·运算符
爱喝水的鱼丶19 天前
SAP-ABAP:SAP概述:数据处理的系统、应用与产品
运维·学习·sap·abap·1024程序员节
1314lay_100720 天前
SAP ABAP 导入excel表,导多个sheet
excel·abap
IT小白农民工23 天前
安装SAP Business one for HANA之前的准备
linux·经验分享·sap
寒武青锋23 天前
SAP 后台批量激活程序
sap·abap
LilySesy1 个月前
ABAP+在select的时候,可以A=B A=C B=C这样子JOIN吗?
数据库·sql·ai·excel·sap·abap
LilySesy1 个月前
ABAP+WHERE字段长度不一致报错解决
java·前端·javascript·bug·sap·abap·alv
海阔天空0921 个月前
ABAP S4 新语法 sql with 的用法demo
abap