2016-08-18 52 views
2

我想在js视图中使用component.js,但它正在为rootview查找xml文件。请帮助我如何编写此文件,以便我可以在js视图中进行路由。如何在js-views中实现sapui5中的component.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"); 
}, 

}); 

回答

0

可以给rootView配置对象,而不是如在documentation描述的字符串:

指定应被打开根视图;可以将视图名称视为 用于XML视图的字符串,或视图名称为视图名称 的视图名称作为字符串和类型的类型(枚举 sap.ui.core.mvc.ViewType)和其他属性 sap.ui.core.mvc.view。

因此,它应该是这样的:

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

但是,如果它不应该是viewType:"JS"这个时间太长我不是舒尔。如果type不起作用,您也应该尝试。

相关问题