找不到ID为" rootControl"的SAPUI5路由问题控件

2020-09-15 11:38发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)我有3个视图,我想在URL中使用...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


我有3个视图,我想在URL中使用"模式"在单独的浏览器标签中加载每个视图:

这是INDEX.html中的脚本:

  

这是manifest.json中的路由配置:

" rootView":{
             " viewName":" com.xxx.yy.myapp.view.App",
             " type":" XML",
             "异步":true
  },
 "路由":{
 " config":{
    " routerClass":" sap.m.routing.Router",
    " viewPath":" com.xxx.yy.myapp.view",
    " controlAggregation":"页面",
    " viewType":" XML",
    " clearTarget":" true",
    "异步":true
  },
  "路线":[{
        " name":" page1",
        "模式":"",
        " target":" page1"
 },{
        " name":" page2",
        " pattern":"事件",
        " target":" page2"
 },{
        " name":" page3",
        " pattern":"团结",
        " target":" page3"
 }],
  "目标":{
     " page1":{
        " viewName":"主要",
        " viewLevel":1,
        " controlId":" rootControl"
      },
      "第2页": {
        " viewName":" EventStatus",
        " viewLevel":1,
        " controlId":" rootControl"
      },
      " page3":{
       " viewName":" EventTrend",
       " viewLevel":1,
       " controlId":" rootControl"
 }} 

com.xxx.yy.myapp.view.App是:

 <查看xmlns =" sap.m" class =" mycss">
 
 
 
 

在component.js中,我有:

 init:函数(){
      //调用基本组件的init函数
       UIComponent.prototype.init.apply(this,arguments)


      //启用路由
       this.getRouter()。initialize();
     //sap.ui.core.UIComponent.getRouterFor(this).attachRoutePatternMatched(this.onRouteMatched,this);
       var oHashChanger = new sap.ui.core.routing.HashChanger();
       var sHash = oHashChanger.getHash();
       console.log("载入页面:",sHash);


      //设置设备型号
       this.setModel(models.createDeviceModel(),'device')
     },


     onRouteMatched:function(oEvent){
       this.sRouteName = oEvent.getParameters()。name;
      //检查路线并重置您的数据
      }
 

问题是有时(在随机模式下)视图无法加载,并且在控制台中发现此错误:

找不到ID为rootControl的控件-EventProvidersap.m.routing.Target

我在哪里错了?

(59.0 kB)
付费偷看设置
发送
2条回答
shere_lin
1楼-- · 2020-09-15 12:15

据我所知," controlId":" rootControl"属性应该存在于"路由"对象内的" config"块中,而不是在每个"目标" blobk中,因此,您的"路由"对象应类似于 下方:

"路由":{"配置":{" routerClass":" sap.m.routing.Router"," viewPath":" com.xxx.yy.myapp.view"," controlId":" rootControl"  ," controlAggregation":"页面"," viewType":" XML"," clearTarget":" true"," async":true}," routes":[{" name":" page1"," pattern":  ""," target":" page1"},{" name":" page2"," pattern":"事件"," target":" page2"},{" name":" page3"," pattern"  ::" unitt"," target":" page3"}]," targets":{" page1":{" viewName":" Main"," viewLevel":1}," page2":{" viewName":"  EventStatus"," viewLevel":1}," page3":{" viewName":" EventTrend"," viewLevel":1}} 
一只江湖小虾
2楼-- · 2020-09-15 12:15

是的,但是我尝试了很多 解决方案(最后是将controlId移到每个"目标"块中)。

无论如何,这两种方法都不起作用。

一周热门 更多>