UI5 路由 - 根据按下的按钮路由到不同的对象目标

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

我的 Master.controller 中有以下代码:

if (sTab === "headers") {
    this.getRouter().navTo("objectHeader", {
        Posid : oItem.getBindingContext().getProperty("Posid")
    }, bReplace);
} else {
    this.getRouter().navTo("object", {
        Posid : oItem.getBindingContext().getProperty("Posid")
    }, bReplace);
}

我认为这意味着这将根据变量“sTab”的结果路由到不同的对象页面,但事实并非如此。 它总是路由到“object”,并且似乎永远不会点击“objectHeader”。

清单:

"routing": {
            "config": {
                "routerClass": "sap.f.routing.Router",
                "viewType": "XML",
                "viewPath": "[redacted].view",
                "controlId": "layout",
                "controlAggregation": "beginColumnPages",
                "bypassed": {
                    "target": "notFound"
                },
                "async": true
            },
            "routes": [
                {
                    "pattern": "",
                    "name": "master",
                    "target": "master"
                },
                {
                    "pattern": "JobSet/{Posid}",
                    "name": "object",
                    "target": [
                        "master",
                        "object"
                    ]
                },
                {
                    "pattern": "JobSet/{Posid}",
                    "name": "objectHeader",
                    "target": [
                        "master",
                        "objectHeader"
                    ]
                }
            ],
            "targets": {
                "master": {
                    "viewName": "Master",
                    "viewLevel": 1,
                    "viewId": "master"
                },
                "object": {
                    "viewName": "Detail",
                    "viewId": "detail",
                    "viewLevel": 1,
                    "controlAggregation": "midColumnPages"
                },
                "objectHeader": {
                    "viewName": "DetailHeader",
                    "viewId": "detailHeader",
                    "viewLevel": 1,
                    "controlAggregation": "midColumnPages"
                },
                "detailObjectNotFound": {
                    "viewName": "DetailObjectNotFound",
                    "viewId": "detailObjectNotFound",
                    "controlAggregation": "midColumnPages"
                },
                "notFound": {
                    "viewName": "NotFound",
                    "viewId": "notFound"
                }
            }
        }

有人可以帮我吗?如果 sTab === "headers" 那么它应该路由到 DetailHeader.view 而不是 Detail.view

sapui5
1个回答
0
投票

在提到的两条路线中都有相同的模式“JobSet/{Posid}”。更改其中一个的模式,这应该有助于解决问题。

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