Routing 找不到ID为app的SAPUI5路由错误控件

Routing 找不到ID为app的SAPUI5路由错误控件,routing,sapui5,Routing,Sapui5,我知道特瑞的问题都是骗人的,但没有一个答案可以解决我的问题。 我想用btn点击从一个页面导航到另一个页面。 当我按下按钮时,控制台中有一个arror: Target-dbg.js:386 Uncaught (in promise) Error: Control with ID app could not be found - Target: TargetReportsView at constructor._refuseInvalidTarget (Target-dbg.js:386) at T

我知道特瑞的问题都是骗人的,但没有一个答案可以解决我的问题。 我想用btn点击从一个页面导航到另一个页面。 当我按下按钮时,控制台中有一个arror:

Target-dbg.js:386 Uncaught (in promise) Error: Control with ID app could not be found - Target: TargetReportsView
at constructor._refuseInvalidTarget (Target-dbg.js:386)
at Target-dbg.js:262
这是我的路由清单:

"routing": {
        "config": {
            "routerClass": "sap.m.routing.Router",
            "viewType": "XML",
            "async": true,
            "viewPath": "CompName.Emp_ITDB.Emp_ITDB.view",
            "controlAggregation": "pages",
            "controlId": "app",
            "clearControlAggregation": false
        },
        "routes": [{
            "name": "RouteMainView",
            "pattern": "RouteMainView",
            "target": ["TargetMainView"]
        }, {
            "name": "TargetReportsView",
            "pattern": "TargetReportsView",
            "greedy": false,
            "target": ["TargetReportsView"]
        }],
        "targets": {
            "TargetMainView": {
                "viewType": "XML",
                "transition": "slide",
                "clearControlAggregation": false,
                "viewId": "MainView",
                "viewName": "MainView"
            },
            "TargetReportsView": {
                "viewType": "XML",
                "viewName": "ReportsView",
                "viewId": "ReportsView"
            }
        }
    }
我的看法是: -主要

}))

我尝试了谷歌能展示给我的一切。 我现在真的很困惑。 我还尝试删除“sap.ui5”中的“rootview”-不起作用。
欢迎任何帮助!提前谢谢

我想主视图是您的根视图?发生此错误是因为主视图中的应用程序没有id,它应该使用id“App”,因为此id在清单中定义为controlId。这样,路由器就可以找到并将其用作导航容器。


<App id="app"> </App>
尝试这样做,这可能会有所帮助

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="CompName.Emp_ITDB.Emp_ITDB.controller.ReportsView" xmlns:html="http://www.w3.org/1999/xhtml">
<App id="TargetReportsView">
    <pages>
        <Page title="Title">
            <content></content>
        </Page>
    </pages>
</App>
sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) {
"use strict";
return Controller.extend("CompName.Emp_ITDB.Emp_ITDB.controller.MainView", {
    /**
     * Called when a controller is instantiated and its View controls (if available) are already created.
     * Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
     * @memberOf CompName.Emp_ITDB.Emp_ITDB.view.MainView
     */

    getRouter : function () {
        return sap.ui.core.UIComponent.getRouterFor(this);
    },

    onInit: function () {},
    /**
     *@memberOf CompName.Emp_ITDB.Emp_ITDB.controller.MainView
     */
    ClearSearchBtnPressed: function (oEvent) {
        this.byId("employeeSearchBar").setValue("");
    },
    /**
     *@memberOf CompName.Emp_ITDB.Emp_ITDB.controller.MainView
     */
    NavigateToReports: function (oEvent) {
        this.getOwnerComponent().getRouter().getTargets().display("TargetReportsView");
    }
});
<App id="app"> </App>