对于以下SAPUI5路由方法之间的区别有一个示例感到高兴:
sap.ui.core.routing.Route:
attachMatched()attachPatternMatched()sap.ui.core.routing.Router:
attachRouteMatched()attachRoutePatternMatched()API说明了什么attachMatched(),attachPatternMatched()没有任何区别。
API表示attachRouteMatched():
将event-handler附加
fnFunction到routeMatchedthis 的事件上sap.ui.core.routing.Router。
API表示attachRoutePatternMatched():
将event-handler附加
fnFunction到routePatternMatchedthis 的事件上sap.ui.core.routing.Router。此事件类似于路由匹配。但它只会对具有匹配模式的路由触发,而不会针对其父模式触发Routes。
例如可以使用
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("sap.ui.demo.wt.controller.Detail", {
onInit: function () {
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.getRoute("detail").attachMatched(this._onObjectMatched, this);
// oRouter.attachRouteMatched(this._onObjectMatched, this);
},
_onObjectMatched: function (oEvent) {
this.getView().bindElement({
path: "/" + oEvent.getParameter("arguments").invoicePath,
model: "invoice"
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
要么 …
sapui5 ×1