2015-07-20 57 views
0

我想從xml視圖創建一個sapui5表,但它似乎並沒有工作,當我從Visual Studio中運行它,但是當我在jsfiddle中運行它時,它運行得很好。這是什麼原因?代碼在jsfiddle中工作,但不在html文檔中。爲什麼?

這裏是我的xmlTest.hml代碼:

<!DOCTYPE html> 
<html> 
<head> 
    <script src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" id="sap-ui-bootstrap" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-libs="sap.ui.commons,sap.ui.table"></script> 
    <meta charset="utf-8"> 
    <title>JS Bin</title> 
</head> 

<body class="sapUiBody" id="content"> 

    <script id="view1" type="ui5/xmlview"> 
     <core:view xmlns:core="sap.ui.core" 
        xmlns="sap.ui.commons" 
        xmlns:table="sap.ui.table" 
        xmlns:html="http://www.w3.org/1999/xhtml" 
        controllername="view.Main"> 
      <table:table width="100%" visiblerowcount="5" selectionmode="Single" editable="false" rows="{/data}"> 
       <table:title><label text="XML View"></label></table:title> 
       <table:column> 
        <label text="Row Num" /> 
        <table:template><textfield value="{rowNum}"></textfield></table:template> 
       </table:column> 
       <table:column> 
        <label text="ID" /> 
        <table:template><textfield value="{id}"></textfield></table:template> 
       </table:column> 
       <table:column> 
        <label text="First Name" /> 
        <table:template><textfield value="{name}"></textfield></table:template> 
       </table:column> 
       <table:column> 
        <label text="Email Address" /> 
        <table:template><textfield value="{email}"></textfield></table:template> 
       </table:column> 

      </table:table> 
     </core:view> 
    </script> 
    <script type="text/javascript"> 
     var aData = [ 
     { rowNum: 1, id: 42, name: "Anthony", email: "[email protected]" }, 
     { rowNum: 1, id: 42, name: "Anthony", email: "[email protected]" }, 
     { rowNum: 1, id: 42, name: "Anthony", email: "[email protected]" }, 
     ]; 
     sap.ui.controller("view.Main", { 
      doSomething: function (oEvent) { } 
     }); 

     var oView = sap.ui.xmlview({ 
      viewContent: jQuery("#view1").html() 
     }); 
     var oModel = new sap.ui.model.json.JSONModel({ 
      data: aData 
     }); 
     oView.setModel(oModel); 
     oView.placeAt("content"); 
    </script> 
</body> 
</html> 

運行從Visual Studio這個代碼,我得到了以下錯誤:

enter image description here

這些錯誤是指this file

當我將我的代碼複製到jsfiddle時,它工作得很好。這是我的jsfiddle

+2

你可以在瀏覽器中將這些鏈接拉到404上嗎? – jackncoke

+1

您的視覺工作室軟件或後臺中的設置90%可能發生了什麼 –

+0

未加載JavaScript文件...您需要確保路徑正確。 –

回答

1

的問題是你用小寫<表:t鍵的能夠> <表:牛逼能夠>

類名是Table,不table,這樣的文件無法找到(它Table.js,不table.js

在你的jsfiddle你使用了正確的外殼

相關問題