小编n01*_*dea的帖子

SAPUI5中的attachMatched()和attachPatternMatched()和/或attachRouteMatched()和attachRoutePatternMatched()有什么区别?

对于以下SAPUI5路由方法之间的区别有一个示例感到高兴:

sap.ui.core.routing.Route

  • attachMatched()
  • attachPatternMatched()

sap.ui.core.routing.Router

  • attachRouteMatched()
  • attachRoutePatternMatched()

API说明了什么attachMatched()attachPatternMatched()没有任何区别。

API表示attachRouteMatched()

将event-handler附加fnFunctionrouteMatchedthis 的事件上 sap.ui.core.routing.Router

API表示attachRoutePatternMatched()

将event-handler附加fnFunctionroutePatternMatchedthis 的事件上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

6
推荐指数
1
解决办法
4840
查看次数

标签 统计

sapui5 ×1