Sapui5 数据在第二个视图中不可见

Sapui5 数据在第二个视图中不可见,sapui5,Sapui5,我面临的一个问题是数据在我的项目中不可见 我创建了两个视图:Input.view.xml和plant.view.xml。在我的第一个视图中,我有一个“Material Details”按钮,单击该按钮,它将移动到第二个视图。然而,它是空白的 我的JSON文件包含了所有数据,但它不会出现在第二视图中 你能建议一下问题是什么以及如何解决吗 “输入视图”(第一视图) Component.js 我猜这在示例中已经得到了很好的回答,从可能的重复中我猜这在示例中已经得到了很好的回答,从可能的重复中 <

我面临的一个问题是数据在我的项目中不可见

我创建了两个视图:
Input.view.xml
plant.view.xml
。在我的第一个视图中,我有一个“Material Details”按钮,单击该按钮,它将移动到第二个视图。然而,它是空白的

我的JSON文件包含了所有数据,但它不会出现在第二视图中

你能建议一下问题是什么以及如何解决吗

“输入视图”(第一视图) Component.js
我猜这在示例中已经得到了很好的回答,从可能的重复中我猜这在示例中已经得到了很好的回答,从可能的重复中
<mvc:View
    controllerName="stock.controller.main"
    xmlns:l="sap.ui.layout"
    xmlns:mvc="sap.ui.core.mvc"
    xmlns:viz="sap.viz.ui5.controls"
    xmlns="sap.m">
    <App id="app">
        <l:VerticalLayout
            class="sapUiContentPadding"
            width="100%"
            height="100%">
            <Label
                text="Product"
                labelFor="productInput" />
            <Input id="productInput"
                placeholder="Enter Material ..."
                showSuggestion="true"
                showTableSuggestionValueHelp="false"
                suggestionRows="{/ProductCollection}"
                suggestionItemSelected="onSelectItem">
                <suggestionColumns>
                    <Column
                        hAlign="Begin"
                        popinDisplay="Inline"
                        demandPopin="true">
                        <Label text="Name"/>
                    </Column>
                </suggestionColumns>
                <suggestionRows>
                    <ColumnListItem>
                        <Label id="inputKey" text="{ProductId} {Name}"/>
                    </ColumnListItem>
                </suggestionRows>
            </Input>
            <Button id="onDisplay"
                text="{i18n>materialDetails}"
                press="onDisplayPlant"
                class="sapUiTinyMarginEnd" />
        </l:VerticalLayout>
    </App>
</mvc:View>
<mvc:View
    controllerName="stock.controller.plant"
    xmlns="sap.m"
    xmlns:viz="sap.viz.ui5.controls"
    xmlns:l="sap.ui.layout"
    xmlns:mvc="sap.ui.core.mvc">
    <MessagePage
        showNavButton="true"
        navButtonPress="onNavBack"/>
        <Table id="idProductsTable"
            inset="false"
            items="{
                path: '/ProductCollection',
                sorter: {
                    path: 'Name'
                }
            }">
            <headerToolbar>
                <Toolbar>
                    <Title text="Products" level="H2" />
                </Toolbar>
            </headerToolbar>
            <columns>
                <Column width="12em">
                    <Text text="Product" />
                </Column>
                <Column
                    minScreenWidth="Tablet"
                    demandPopin="true">
                    <Text text="Supplier" />
                </Column>
                <Column
                    minScreenWidth="Tablet"
                    demandPopin="true"
                    hAlign="End">
                    <Text text="Dimensions" />
                </Column>
                <Column
                    minScreenWidth="Tablet"
                    demandPopin="true"
                    hAlign="Center">
                    <Text text="Weight" />
                </Column>
                <Column hAlign="End">
                    <Text text="Price" />
                </Column>
            </columns>
            <items>
                <ColumnListItem>
                    <ObjectIdentifier
                        title="{Name}"
                        text="{ProductId}"/>
                    <Text text="{SupplierName}" />
                    <Text text="{Width} x {Depth} x {Height} {DimUnit}" />
                    <ObjectNumber
                        number="{WeightMeasure}"
                        unit="{WeightUnit}"
                        state="{
                            parts: [
                                {path: 'WeightMeasure'},
                                {path: 'WeightUnit'}
                            ],
                            formatter: 'stock.Formatter.weightState'
                        }" />
                    <ObjectNumber
                        number="{
                            parts: [{
                                path: 'Price'
                            }, {
                                path: 'CurrencyCode'
                            }],
                            type: 'sap.ui.model.type.Currency',
                            formatOptions: {
                                showMeasure: false
                            }
                        }"
                        unit="{CurrencyCode}" />
                </ColumnListItem>
            </items>
        </Table>
    </MessagePage>
</mvc:View>
sap.ui.define([
    "sap/ui/core/mvc/Controller",
    "jquery.sap.global",
    "stock/Formatter",
    "sap/ui/core/routing/History",
    "sap/ui/model/json/JSONModel"
], function (Controller, jQuery, Formatter, History,JSONModel) {
    "use strict";

    var TableController =  Controller.extend("stock.controller.plant", {
        onInit: function () {
            var oModel = new JSONModel(jQuery.sap.getModulePath("sap.ui.demo.mock", "/products.json"));
            this.getView().setModel(oModel);
        },

        getRouter : function () {
            return sap.ui.core.UIComponent.getRouterFor(this);
        },

        onNavBack: function () {
            var oHistory = History.getInstance();
            var sPreviousHash = oHistory.getPreviousHash();
            if (sPreviousHash !== undefined) {
                window.history.go(-1);
            } else {
                this.getRouter().navTo("input", {}, true);
            }
        }
    });
    return TableController;
});
sap.ui.define([
    "sap/ui/core/UIComponent",
    "sap/ui/core/mvc/XMLView",
    "sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel, XMLView) {
    "use strict";

    var Component = UIComponent.extend("stock.Component", {
        metadata: {
            manifest: "json",
            getTable: function () {
                return this._rootView.getContent()[0];
            }
        },
        publicMethods: [
            "getTable"
        ],
        dependencies: {
            libs: [
                "sap.m",
                "sap.ui.layout"
            ]
        },
        rootView: "stock.view.input",
        config: {
            sample: {
                files: [
                    "view.input.view.xml",
                    "controller.main.controller.js",
                    "Formatter.js"
                ],
                description : "In this example assisted input is provided with table-like suggestions where several columns can display more details."
            }
        },

        init : function () {
            UIComponent.prototype.init.apply(this, arguments);
            this.getRouter().initialize();
        }
    });

    Component.prototype.createContent = function () {
        this._rootView = sap.ui.xmlview({ viewName : "stock.view.plant" });
        return this._rootView;
    };

    return Component;
});