在 XML 中寻址事件处理程序:`.myHandler` 或 `myHandler`?
Addressing event handlers in XML: `.myHandler` or `myHandler`?
我注意了,在一些 UI5 示例中,我可以看到 press=".onCloseDialog"
,在另一个示例中:press="onCloseDialog"
。
我的意思是,在某些情况下,XML-template 中控制器方法的名称是用前导点写的,有时没有。是品味问题吗?
Is it a matter of a taste?
没有。根据Addressing the Event Handler:
- Names starting with a dot ('.') are always assumed to represent a method in the controller. [...] These names are relative to the view/controller. For example,
press=".myLocalHandler"
is resolved by attachPress(oController["myLocalHandler"], oController);
.
- Names without dot are interpreted as a relative name; if nothing is found, they are interpreted as an absolute name. This variant is only supported for backward compatibility.
--> 另见 message from the commit 226bc69
.
在引用控制器方法时始终使用 press="<strong>.</strong>onCloseDialog"
。
我注意了,在一些 UI5 示例中,我可以看到 press=".onCloseDialog"
,在另一个示例中:press="onCloseDialog"
。
我的意思是,在某些情况下,XML-template 中控制器方法的名称是用前导点写的,有时没有。是品味问题吗?
Is it a matter of a taste?
没有。根据Addressing the Event Handler:
- Names starting with a dot ('.') are always assumed to represent a method in the controller. [...] These names are relative to the view/controller. For example,
press=".myLocalHandler"
is resolved byattachPress(oController["myLocalHandler"], oController);
.- Names without dot are interpreted as a relative name; if nothing is found, they are interpreted as an absolute name. This variant is only supported for backward compatibility.
--> 另见 message from the commit 226bc69
.
在引用控制器方法时始终使用 press="<strong>.</strong>onCloseDialog"
。