主详细信息上的 SAPUI5 自定义导航路由器



我正在扩展现有的FIORI应用程序。该应用是主从应用。我在导航到自定义详细信息页面时遇到问题。顺便说一下,我正在使用SAP WEB IDE。

这是我在主视图控制器上实现的代码段。 我可以毫无问题地获得 Matnr。

  this.oRouter.navTo("newView",{
     Matnr :  i.getBindingContext().getProperty("Matnr")
  });

这是我组件的一部分.js

this.cus.sd.salesorder.create.Component.extend("cus.sd.salesorder.create.SD_SO_CREExtension.Component", {
    metadata: {
        version: "1.0",
        routing: 
        {
            "routes" : {
                "newView": {
                "pattern": "newView/{Matnr}",
                 "view":"cus.sd.salesorder.create.SD_SO_CREExtension.view.CustomView",

                }
            },
         },

这是我的自定义视图视图

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
    controllerName="cus.sd.salesorder.create.SD_SO_CREExtension.view.CustomView" xmlns:html="http://www.w3.org/1999/xhtml">
    <App>
        <pages>
            <Page title="Title">
                <content>
                    <Label text = "hello"></Label>
                </content>
            </Page>
        </pages>
    </App>
</mvc:View>

这是控制器

    sap.ui.define([
        "sap/ui/core/mvc/Controller"
    ], function(Controller) {
        "use strict";
        return Controller.extend("cus.sd.salesorder.create.SD_SO_CREExtension.view.CustomView", {
                onInit: function() {
                    alert("hello");
                },
        });
});

检查 URL 后,它似乎正在访问它

....sap-ui-xx-componentPreload=off&origional-url=index.html&sap-ui-appCacheBuster=..%2F#&/newView/14

但是我看不到任何标签组件。

由于您使用的是SAP WebIDE,因此可以考虑使用扩展项目。使用扩展项目可以避免一些手动编码。从原始项目的上下文菜单中,转到"新建>扩展项目"。这将创建一个引用原始项目的项目。然后,您可以决定是要复制原始视图并对其进行调整,还是从头开始创建自己的视图。可以通过进入扩展项目>"工具">"扩展性"来执行此操作。在窗格中,展开要调整/扩展的视图>鼠标右键单击>,您可以复制和调整,或编写自己的视图。您可以在扩展 SAPUI5 应用程序下的帮助中找到更多信息。

最新更新