sapui5 统一中的导航问题 Shell (sap.ui.unified.Shell)

Navigation Problems in a sapui5 unified Shell (sap.ui.unified.Shell)

为了实现类似 facebook 的滑动菜单,我使用了统一的 Shell 控件,并在其中集成了一个列表,以便我可以输入菜单项。这个想法是,当用户单击菜单中的某个列表项时,他将被重定向到一个新视图。我尝试使用 bus.publish("nav", "to" {id:..}) 来实现它,但它不起作用。 (我已经把菜单放在统一的窗帘面板Shell)谁能帮帮我? 您可以在下面找到视图和控制器各自的代码片段。

var oListTemplate = new sap.m.StandardListItem({
            title: "{title}",
            icon: "{icon}",
            description: "{description}",
            type: sap.m.ListType.Navigation,
            customData: new sap.ui.core.CustomData({
                key: "targetPage",
                value: "{targetPage}"
            })
        });

        var oList = new sap.m.List({
            selectionChange: [oController.doNavOnSelect, oController],
            mode: sap.m.ListMode.SingleSelectMaster
        });
        oList.bindAggregation("items", "/Menu", oListTemplate);

控制器:

onInit: function() {

        this.getView().setModel(new sap.ui.model.json.JSONModel("model/menu.json"));
       this.bus = sap.ui.getCore().getEventBus();
    },


 doNavOnSelect: function(event){
     if (sap.ui.Device.system.phone) {
            event.getParameter("listItem").setSelected(false);
        }
     this.bus.publish("nav", "to", {
            id: event.getParameter('listItem').getCustomData()[0].getValue()
        });

通过 sap.ui.core.EventBus 的导航已过时。 请查看 SAPUI5 导航和路由 http://help.sap.com/saphelp_hanaplatform/helpdata/en/68/8f36bd758e4ce2b4e682eef4dc794e/content.htm

A new Routing mechanism was introduced to UI5 in release 1.16. For in-app navigation, this supersedes previous techniques such as using the sap.ui.core.EventBus or sharing navigation-container specific controller code amongst aggregated pages.

解决方法:将bus.publish替换为app.to

doNavOnSelect: function(event){
    if (sap.ui.Device.system.phone) {
            event.getParameter("listItem").setSelected(false);
        }

    app.to(event.getParameter('listItem').getCustomData()[0].getValue());

    }