[英]Code works in jsfiddle but not in html document. Why?
I am trying to create a sapui5 table from xml view but it doesn't seem to be working when I run it from visual studio but when I run it in jsfiddle it runs just fine. 我正在尝试从xml视图创建sapui5表,但是当我从Visual Studio中运行它时似乎无法正常工作,但是当我在jsfiddle中运行它时,它就可以正常运行。 What is the reason for this?
这是什么原因呢?
Here is the code in my xmlTest.hml: 这是我的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: "anthony@example.com" },
{ rowNum: 1, id: 42, name: "Anthony", email: "anthony@example.com" },
{ rowNum: 1, id: 42, name: "Anthony", email: "anthony@example.com" },
];
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>
Running this code from visual studio I get the following errors: 从Visual Studio运行此代码时,出现以下错误:
These errors refer to this file . 这些错误引用此文件 。
When I copy my code into jsfiddle it works just fine. 当我将代码复制到jsfiddle中时,它可以正常工作。 Here is my jsfiddle .
这是我的jsfiddle 。
The issue is you used lowercase <table: t able> instead of <table: T able> 问题是你用小写<表:T能够>,而不是<表:T能够>
The class name is Table
, not table
, and as such the file cannot be found (it's Table.js
, not table.js
) 类名是
Table
,不是table
,因此找不到该文件(它是Table.js
,不是table.js
)
In your JSFiddle you used the correct casing 在您的JSFiddle中,您使用了正确的大小写
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.