SAPUI5 路由 - 找不到 ID 为 idAppControl 的控件

SAPUI5 routing - Control with ID idAppControl could not be found

首先,我知道有类似的问题,但是 none 的答案可以解决我的问题。

简要查看我的代码:

我的Component.js看起来像这样

routes: [
            {
                pattern: "",                //home page
                name: util.Constants.Tile,
                view: util.Constants.Tile,
                viewId: util.Constants.Tile,
                targetAggregation: "pages"
                //targetControl: "idAppControl"
            },
            {
                pattern: "firstExample",
                name: util.Constants.FirstExample,
                view: util.Constants.FirstExample,
                viewId: util.Constants.FirstExample,
                targetAggregation: "pages",
                targetControl : "idAppControl",
                subroutes : [
                    {
                        pattern: "firstExample",
                        name: util.Constants.ExampleMaster,
                        view: util.Constants.ExampleMaster,
                        targetAggregation: "masterPages",
                        targetControl: "idSplitContainerControl",
                    },
                    {
                        pattern: "firstExample/:typeMaster:",
                        name: util.Constants.ExampleSecondMaster,
                        view: util.Constants.ExampleSecondMaster,
                        targetAggregation: "masterPages",
                        targetControl: "idSplitContainerControl",
                        subroutes : [
                            {
                                pattern : "firstExample/:typeDetail:",
                                name : util.Constants.ExampleDetail,
                                view : util.Constants.ExampleDetail,
                                targetAggregation : "detailPages"
                            }
                        ]
                    }
                ]
            },

简短说明:这是一个包含普通应用程序视图(无主视图)和后续 SplitContainer 的页面,其中包含两个主视图和一个详细视图。每当我想调用详细视图时

onSelect : function (e) {
    var routeTo = e.getSource().getTitle();

    this.router.navTo(util.Constants.ExampleDetail, { typeDetail : routeTo } );

},

它说

2015-03-30 14:50:06 Control with ID idAppControl could not be found - sap-ui-core-dbg.js:15213

有什么想法吗? 提前感谢您的帮助!


类似主题的链接:

很难调试别人的路由代码,所以这是我的多页面应用程序的工作路由器。第一个是带有图块的简单页面,第二个是 Master/Detail 视图。

routes : [
    {
        pattern : "",
        name: "launchpad",
        view: "Launchpad",
        targetControl: "masterView"
    },
    {
        pattern : "split",
        name: "app",
        view: "App",
        targetControl: "masterView",
        subroutes : [
            {
                pattern : "master",
                name : "main",
                // placed in master masterPages aggregation of splitapp
                view : "Master",
                targetAggregation : "masterPages",
                targetControl : "idAppControl",
                // places detail in detailPages aggreg. of the splitapp
                subroutes : [
                    {
                        // product context is expected
                        // and which tab should be selected (supplier/category)
                        pattern : "{product}/:tab:",
                        name : "product",
                        view : "Detail",
                        targetAggregation :  "detailPages"
                    }
                ]
            }
        ]
    },
    // catchall routes, to show not found message, when route is not valid
    {
        name : "catchallMaster",
        view : "Master",
        targetAggregation : "masterPages",
        targetControl : "idAppControl",
        subroutes : [
            {
                pattern : ":all*:",
                name : "catchallDetail",
                view : "NotFound"
            }
        ]
    }
]
}
// custom routing is performed in MyRouter.js
},

请注意,为两条路线都设置了 targetControl。 masterView 是首先加载的 MasterApp 的一部分。

<mvc:View
    xmlns:mvc="sap.ui.core.mvc"
    displayBlock="true"
    xmlns="sap.m">
    <App
        id="masterView">
    </App>
</mvc:View>

idAppControl 是 App.view.xml 和 <SplitApp id="idAppControl" /> 的一部分。我和您一样,基于开发人员指南中的示例来构建我的应用程序。

Component.js 有这个:

createContent: function() {
    var viewData = {
        component:this
    };
    return sap.ui.view({
        viewName: "sap.ui.demo.app.view.MasterApp",
        type: sap.ui.core.mvc.ViewType.XML,
        viewData: viewData
    });
}

App.view:

<mvc:View
    xmlns:mvc="sap.ui.core.mvc"
    displayBlock="true"
    xmlns="sap.m">
    <SplitApp id="idAppControl" />
</mvc:View>

配置:

routing: {
    config: {
        // custom router class
        routerClass : sap.ui.demo.app.MyRouter,
        // xml views
        viewType : "XML",
        // absolute path to views
        viewPath : "sap.ui.demo.app.view",
        // unless stated otherwise, router places view in detail part
        targetAggregation : "pages",
        // don't clear the detail pages before views are added
        clearTarget : false
    },
}

在查看您的路由器时,我会说您的页面顺序有问题。作为一般建议,我想说 navTo 采用路线的参数 "name",而不是视图或模式。我花了一些时间才知道这一点。

亲切的问候,

迈克尔