XML View无法正常工作

时间:2016-03-18 05:46:25

标签: sapui5

我是UI5的新手并且遵循本教程http://openui5.org/getstarted.html。我在本教程的第3步中遇到了一个问题,我正在创建应用程序的XML视图。数据" Hello World"没有出现在页面上。当我查看控制台时,我看到了这个错误

Failed to load resource: the server responded with a status of 404 (Not Found) https://openui5.hana.ondemand.com/resources/sap-ui-core.js

这是我的代码:

的index.html

<!DOCTYPE html>
  <html>
    <head>
      <meta http-equiv='X-UA-Compatible' content='IE=edge' />
      <title>Hello World</title>
      <script
       id="sap-ui-bootstrap"
       src='https://openui5.hana.ondemand.com/resources/sap-ui-core.js'
       data-sap-ui-theme="sap_bluecrystal"
       data-sap-ui-libs="sap.m"
       data-sap-ui-compatVersion="edge"
       data-sap-ui-preload="async">
      </script>
      <script>
       sap.ui.getCore().attachInit(function(){
       new sap.ui.xmlview({
       viewName: "sap.ui.demo.wt.App"
       }).placeAt("content");
      });
      </script>
    </head>
    <body class="sapUiBody">
      <div id="content"></div>
    </body>
  </html>

App.view.xml

<mvc:View
  xmlns="sap.m"
  xmlns:mvc="sap.ui.core.mvc">
  <Text text="Hello World!" />
</mvc:View>

1 个答案:

答案 0 :(得分:2)

您正在使用带有命名空间sap.ui.demo.wt的视图,但框架并不知道在哪里可以找到此命名空间。

您需要将此定义添加到bootstrap-script-tag:

data-sap-ui-resourceroots='{"sap.ui.demo.wt": "./"}'

查看链接指南,我看到文本中的代码没有此声明,但是中的代码自己尝试 -Box(以及链接的{{ 3}})确实。