SAPUI5 - 为XML中的事件处理程序设置数组有什么作用?

问题描述 投票:1回答:2

我在UI5“Explored”示例中看到了一个看起来像数组的新闻事件:

press="[handleViewSettingsDialogFilterBarPressed, views.control.tableViewSettingsDialog]"

Example在第25行

我理解正常的新闻事件如何运作。使用这样的数组怎么办?我找不到关于它的文档,因此任何关于它如何工作的信息或者它所记录的链接都将非常有用。

sapui5
2个回答
0
投票

这只是一条捷径。也许在示例here中更容易看到这一点。两个处理程序在Controller中调用相同的函数。

sap.ui.jsview("myView.Template", {
  getControllerName: function() {
    return "myView.Template";
  },
  createContent: function(oController) {
    var oBox = new sap.m.HBox({
      items: [
        new sap.m.Button({
          text: 'First',
          press: function(oEvent) {
            oController.press(oEvent);
          }
        }),
        new sap.m.Button({
          text: 'Second',
          press: [oController.press, oController]
        })
      ]
    });
    return oBox;
  }
});

sap.ui.define([
  'jquery.sap.global',
  'sap/ui/core/mvc/Controller',
], function(jQuery, Controller) {
  "use strict";

  var TableController = Controller.extend("myView.Template", {
    press: function(oEvent) {
      alert('press');
    }
  });

  return TableController;

});
//Instantiate View  
var view = sap.ui.view({
  type: sap.ui.core.mvc.ViewType.JS,
  viewName: "myView.Template"
});
view.placeAt("content");

数组中的第一项是调用函数,第二项是绑定对象。

谢谢


0
投票

查看sap.m.Toolbar Constructor下的press event属性的描述:

事件按:fnListenerFunction或[fnListenerFunction,oListenerObject]或[oData,fnListenerFunction,oListenerObject]

© www.soinside.com 2019 - 2024. All rights reserved.