1

我想使用路由在我的详细视图中导航,我遇到了这个错误:

未捕获的 TypeError:sap.ui.core.UIComponent.getRouterFor 不是函数

下面你可以看到 Component.js

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

    metadata : {
        rootView : "iwstoolbarui5.Main",
        routing : {
            config : {
                targetsClass : "sap.m.routing.Targets",
                viewPath : "iwstoolbarui5",
                targetControl: "mainApp",
                controlId : "mainApp",
                controlAggregation : "detailPages",
                viewType : "XML"
            },

            routes:[

                   {

                pattern : "BPIdent",
                name : "Main",
                view : "Main",
                viewLevel : 0,
                targetAggregation : "masterPages",
                targetControl : "mainApp",
                subroutes : [
                        {
                            pattern : "/bpident:",
                            name : "BPIdent",
                            view : "BPIdent.BPIdent",
                            viewLevel : 1,
                            targetAggregation:"detailPages",
                            subroutes : [
                                    {
                                    pattern : "/accounts",
                                    name : "Accounts",
                                    view : "BPIdent.Accounts",
                                    viewLevel : 2,
                                    targetAggregation:"detailPages"
                            }
                        ]   
                   },
             init : function() {
             sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
             this.gerRouter().initialize();
               }

这是我在 BPident 中的功能(这是我的详细信息页面之一)

selectInteraction: function(event) { 
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            this.showDetail(event.getParameter("listItem") ||event.getSource());
},

showDetail : function(oItem) {  
            var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
            sap.ui.core.UIComponent.getRouter(this).navTo("BPIdent", {
                from: "master",
                BPIdent: oItem.getBindingContext().getPath().substr(1)});
        },

这是我的索引的一部分:

sap.ui.getCore().attachInit(function() {
        new sap.ui.core.ComponentContainer({
            name : "iwstoolbarui5"
        });
    });

谁能帮我解决这个问题?

4

0 回答 0