【问题标题】:routing throwing an error Control ID App Could not be found with Target View in SAPUI5路由抛出错误控制 ID 应用程序在 SAPUI5 中的目标视图中找不到
【发布时间】: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


    【解决方案1】:

    您通常需要在清单中定义您的根视图:

    ...
    "sap.ui5": {
          "rootView": {
            "viewName": "emergencyreport1.view.app",
            "type": "XML",
            "async": true,
            "id": "app"
          },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 2014-08-01
      • 1970-01-01
      相关资源
      最近更新 更多