Sapui5在xml中使用我的新控制器

时间:2016-02-24 13:33:44

标签: controls sapui5 extends

这就是我创建新控件的方式:

https://sapui5.hana.ondemand.com/sdk/#docs/guide/91f0a8dc6f4d1014b6dd926db0e91070.html

sap.ui.somelib.SomeControl.extend("my.OwnControl", {
       ...
       init: function() {
             if (sap.ui.somelib.SomeControl.prototype.init) { // check whether superclass implements the method
                    sap.ui.somelib.SomeControl.prototype.init.apply(this, arguments); // call the method with the original arguments
             }

             //... do any further initialization of your subclass... 
       } 

可以在我的xml视图中使用一些控制器吗?

1 个答案:

答案 0 :(得分:0)

定义这样的控件时: sap.ui.core.Control.extend("my.Square", ...

并声明XML命名空间 xmlns:my="my"

您可以像这样使用您的控件: <my:Square text="test" size="100px"/>

但是,只有当您将控件声明为现有模块时: jQuery.sap.declare("my.Square"); (最后一部分在另一个答案中缺失)

以下是文档中“Square”控件的运行示例: http://jsbin.com/zuxebev/1/edit?html,output