路由抛出错误 Control ID App Couldnot be found with Target View in SAPUI5
routing throwing an error Control ID App Could not be found with Target View in SAPUI5
我需要通过路由从 View1 导航到 view2。单击事件时,它会引发错误。
错误:找不到带有 ID 应用程序的控件 - 目标:View2
我创建了一个空 app.view 文件并将其 ID 添加为“app”,但仍然抛出错误。
manifest.json
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "emergencyreport1.view",
"controlAggregation": "pages",
"controlId": "app"
},
"routes": [
{
"name": "View1",
"pattern": "",
"target": ["View1"]
},
{
"name": "View2",
"pattern": "View2",
"target": ["View2"]
}
],
"targets": {
"View1": {
"viewType": "XML",
"transition": "slide",
"viewId": "View1",
"viewName": "View1",
"viewLevel" : 1
},
"View2": {
"viewType": "XML",
"transition": "slide",
"viewId": "View2",
"viewName": "View2",
"viewLevel" : 2
}
}
app.view.xml
<mvc:View
controllerName="emergencyreport1.controller.app"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns="sap.m">
<App id="app" >
</App>
</mvc:View>
View1.xml
<mvc:View
controllerName="emergencyreport1.controller.View1"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns="sap.m">
<App>
<core:Icon src="sap-icon://display-more" press="ondisplay" />
</App>
</mvc:View>
View1.controller
ondisplay: function ()
{
this.getOwnerComponent().getRouter().navTo("View2");
}
您通常需要在清单中定义根视图:
...
"sap.ui5": {
"rootView": {
"viewName": "emergencyreport1.view.app",
"type": "XML",
"async": true,
"id": "app"
},
我需要通过路由从 View1 导航到 view2。单击事件时,它会引发错误。 错误:找不到带有 ID 应用程序的控件 - 目标:View2 我创建了一个空 app.view 文件并将其 ID 添加为“app”,但仍然抛出错误。
manifest.json
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "emergencyreport1.view",
"controlAggregation": "pages",
"controlId": "app"
},
"routes": [
{
"name": "View1",
"pattern": "",
"target": ["View1"]
},
{
"name": "View2",
"pattern": "View2",
"target": ["View2"]
}
],
"targets": {
"View1": {
"viewType": "XML",
"transition": "slide",
"viewId": "View1",
"viewName": "View1",
"viewLevel" : 1
},
"View2": {
"viewType": "XML",
"transition": "slide",
"viewId": "View2",
"viewName": "View2",
"viewLevel" : 2
}
}
app.view.xml
<mvc:View
controllerName="emergencyreport1.controller.app"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns="sap.m">
<App id="app" >
</App>
</mvc:View>
View1.xml
<mvc:View
controllerName="emergencyreport1.controller.View1"
xmlns:mvc="sap.ui.core.mvc"
displayBlock="true"
xmlns="sap.m">
<App>
<core:Icon src="sap-icon://display-more" press="ondisplay" />
</App>
</mvc:View>
View1.controller
ondisplay: function ()
{
this.getOwnerComponent().getRouter().navTo("View2");
}
您通常需要在清单中定义根视图:
...
"sap.ui5": {
"rootView": {
"viewName": "emergencyreport1.view.app",
"type": "XML",
"async": true,
"id": "app"
},