【发布时间】:2021-08-18 06:18:41
【问题描述】:
我需要通过路由从 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");
}
【问题讨论】:
标签: sapui5