此问题源自this answer(我无法运行源代码),我的要求类似于this question,这是一个带有app控件的页面,导航到SplitContainer一个主视图和一个详细视图。 Master.view.xml已成功加载,但我得到了
单击项目时出现"无法找到使用ID应用控件"
错误。
我的metadata.json:
"routing": {
"config": {
"routerClass": "cts.alert.MyRouter",
"viewType": "XML",
"viewPath": "cts.alert.view",
"controlId": "app",
"controlAggregation": "pages",
"clearTarget": "false",
"bypassed": {
"target": [
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "worklist",
"target": [
"worklist"
]
},
{
"pattern": "split",
"name": "split",
//<SplitContainer id="idAppControl"> in SplitApp.view.xml
"view": "SplitApp",
//<App id="app"/> in App.view.xml
"targetControl": "app",
"subroutes": [
{
"pattern": "master",
"name": "main",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl", //SplitContainer id
"subroutes": [
{
"pattern": "VEHICLES/{objectId}",
"name": "object",
"view": "Detail",
"targetAggregation": "detailPages",
}
]
}
]
},
{
"name": "catchallMaster",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": ":all*:",
"name": "catchallDetail",
"view": "NotFound"
}
]
}
],
"targets": {
"master": {
"viewName": "Master",
"viewLevel": 2,
"viewId": "master",
"controlAggregation": "masterPages"
},
"worklist": {
"viewName": "Worklist",
"viewId": "worklist",
"viewLevel": 1
},
"object": {
"viewName": "Detail",
"viewId": "detail",
"viewLevel": 3
},
"objectNotFound": {
"viewName": "ObjectNotFound",
"viewId": "objectNotFound"
},
"notFound": {
"viewName": "NotFound",
"viewId": "notFound"
},
"detailObjectNotFound": {
"viewName": "DetailObjectNotFound",
"viewId": "detailObjectNotFound"
},
"detailNoObjectsAvailable": {
"viewName": "DetailNoObjectsAvailable",
"viewId": "detailNoObjectsAvailable"
}
}
}
我不确定子路由是否还需要这么多目标。我知道问题出在"targetControl" : "app"
路由"split"
中,但是如果我添加&#34; targetControl&#34; :&#34; idAppControl&#34;在"object"
路线中,它也会产生
无法找到ID为idAppControl的控件
您无法加入与您的父路线相同的控件。
我现在很困惑。
我还尝试在"rootview"
中删除"sap.ui5"
,但没有工作。
欢迎任何帮助!提前致谢!
答案 0 :(得分:2)
感谢route configuration doc,我解决了我的问题。
我认为导致此错误的"targetControl": "app"
路由split
,但实际上是因为"controlId": "app"
routing.config
导致此问题。
config参数定义路由配置的默认值。
更改后,我又出现了另一个错误:
目标工作清单没有设置controlId且没有父级,因此无法显示目标。
所以我删除了target
路由中的worklist
并在其中添加了targetControl: app
,因为它不再具有默认的targetControl
值。
以下是新路线配置:
"routing": {
"config": {
"routerClass": "cts.alert.MyRouter",
"viewType": "XML",
"viewPath": "cts.alert.view",
"controlAggregation": "pages",
"clearTarget": "false",
"bypassed": {
"target": [
"notFound"
]
},
"async": true
},
"routes": [
{
"pattern": "",
"name": "worklist",
"view": "Worklist",
"targetControl": "app"
},
{
"pattern": "split",
"name": "split",
"view": "SplitApp",
"targetControl": "app",
"subroutes": [
{
"pattern": "master",
"name": "main",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": "VEHICLES/{objectId}",
"name": "object",
"view": "Detail",
"targetAggregation": "detailPages"
}
]
}
]
},
{
"name": "catchallMaster",
"view": "Master",
"targetAggregation": "masterPages",
"targetControl": "idAppControl",
"subroutes": [
{
"pattern": ":all*:",
"name": "catchallDetail",
"view": "NotFound"
}
]
}
],
}
答案 1 :(得分:0)
我想说的是manifest.json("controlId": "app"
)中的“ app”值
还需要在初始视图中匹配该应用的ID
<mvc:View controllerName="MyView" xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml">
<Shell id="shell">
<App id="app">