【问题标题】:how to implement component.js in js-views in sapui5 for routing如何在sapui5的js-views中实现component.js进行路由
【发布时间】:2016-12-24 22:51:10
【问题描述】:

我想在 js 视图中使用 component.js,但它正在使用 rootview 来搜索 xml 文件。请帮助我应该如何编写这个文件,以便我可以在 js 视图中进行路由。

jQuery.sap.declare("com.resident.Component");
sap.ui.core.UIComponent.extend("com.resident.Component", {

metadata : {
  rootView : "com.resident.residentbhartiya.App",
  routing : {
   config : {
    targetsClass : "sap.m.routing.Targets",
    viewPath : "com.resident.residentbhartiya",
    controlId : "rootControl",
    controlAggregation : "pages",
    viewType : "JS"
   },
   targets : {
    page1 : {
     viewName : "loginpage",
     viewLevel : 0
    },

    page2 : {
     viewName : "homepage",
     viewLevel : 1
    }
   }
  }
},

init : function() {
     sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
     this.getTargets().display("page1");
},

});

【问题讨论】:

标签: javascript views sapui5 component.js


【解决方案1】:

你可以给rootView一个配置对象,而不是documentation中描述的字符串:

指定要打开的根视图;可以是视图名称 XML 视图的字符串,或带有 viewName 的视图配置对象 视图名称为字符串,类型为类型(枚举 sap.ui.core.mvc.ViewType) 和其他属性 sap.ui.core.mvc.view.

所以它应该是这样的:

metadata:{
   rootView: {
      viewName: "com.resident.residentbhartiya.App",
      type:"JS"
   } 
  ... 

但是,如果这次不应该是viewType:"JS",我不知道。如果type 不起作用,您也应该尝试一下。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-09
    • 2019-12-19
    相关资源
    最近更新 更多