未显示UI5 xml-view的内容

时间:2017-09-07 15:15:53

标签: sapui5

我已经定义了一个简单的xml-view,如下所示:

<mvc:View controllerName="ui5_wt_confirm.controller.Login" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc">
<Page title="{i18n>helloPanelTitle}">
    <subHeader>
        <Toolbar>

        </Toolbar>
    </subHeader>
    <content>
        <Button text="{i18n>showHelloButtonText}" press="onShowHello" class="myCustomButton"/>
        <Input value="{/recipient/name}" valueLiveUpdate="true" width="60%"/>
        <Text text="Hello {/recipient/name}" class="sapUiSmallMargin sapThemeHighlight-asColor myCustomText"/>
    </content>
    <footer>
        <Toolbar>
            <ToolbarSpacer/>
            <Button text="{i18n>showLoginButtonText}" type="Accept" press="onLogin"/>
            <Button text="{i18n>showExitButtonText}" type="Reject"/>
        </Toolbar>
    </footer>
</Page>

但由于某种原因,内容标记中的元素将不会显示:

enter image description here

你能告诉我这里有什么问题吗?

谢谢,BR。

1 个答案:

答案 0 :(得分:0)

Page放入sap.m.App

&#13;
&#13;
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta charset="UTF-8">

        <title>List example</title>
      
        <script id="sap-ui-bootstrap" 
                type="text/javascript"
                src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
                data-sap-ui-theme="sap_bluecrystal"
                data-sap-ui-libs="sap.ui.commons, sap.m"
                data-sap-ui-xx-bindingSyntax="complex">
        </script>


        <!-- XML-based view definition mode="SingleSelectMaster" -->
        <script id="view1" type="sapui5/xmlview">
          <mvc:View controllerName="ui5_wt_confirm.controller.Login" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc">
          <App>
            <Page title="{i18n>helloPanelTitle}">
                <subHeader>
                    <Toolbar>

                    </Toolbar>
                </subHeader>
                <content>
                    <Button text="Hello" press="onShowHello" class="myCustomButton"/>
                    <Input value="Dummy" valueLiveUpdate="true" width="60%"/>
                    <Text text="Hello Dummy" class="sapUiSmallMargin sapThemeHighlight-asColor myCustomText"/>
                </content>
                <footer>
                    <Toolbar>
                        <ToolbarSpacer/>
                        <Button text="Login" type="Accept" press="onLogin"/>
                        <Button text="Exit" type="Reject"/>
                    </Toolbar>
                </footer>
            </Page>
            </App>
            </mvc:View>
        </script>

        <script>

            // Controller definition
            sap.ui.controller("ui5_wt_confirm.controller.Login", {
              onInit: function() {
              }
            });
           
            // Instantiate the View, assign a model
            // and display
            var oView = sap.ui.xmlview({
                viewContent: jQuery('#view1').html()
            });
               
            oView.placeAt('content');

        </script>

    </head>
 
    <body class="sapUiBody" role="application">
        <div id="content"></div>
    </body>
</html>
&#13;
&#13;
&#13;