首先,我知道有类似的问题,但没有一个答案可以解决我的问题。
仔细查看我的代码:
My 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无法找到ID为idAppControl的控件 - sap-ui-core-dbg.js:15213
有什么想法吗? 感谢您的帮助!
指向类似主题的链接:
答案 0 :(得分:6)
调试其他人的路由代码很困难,所以这是我的工作路由器,用于多页面应用程序。第一个是带有图块的简单页面,第二个是主/明细视图。
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是带有<SplitApp id="idAppControl" />
的App.view.xml的一部分。我的应用程序基于开发人员指南中的示例,就像您一样。
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”,而不是视图或模式。花了我一些时间来学习。
亲切的问候,
迈克尔