[英]Uncaught (in promise) TypeError: Cannot read property 'ui5' of undefined
When I try to create a BarChart in js view tab, it gives me this error. 当我尝试在js视图选项卡中创建BarChart时,它给了我这个错误。 Here is my html code 这是我的HTML代码
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
<link rel="stylesheet" type="text/css" href="Styles/MainPage.css"/>
<script src="resources/sap-ui-core.js"
id="sap-ui-bootstrap"
data-sap-ui-libs="sap.m, sap.viz"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->
<script>
sap.ui.localResources("empcrud");
//sap.ui.localResources("Styles");
var app = new sap.m.App("AppId", { initialPage: "idEMainPage1" });
var page = sap.ui.view({ id: "idEmpDetails1", viewName: "empcrud.EmpDetails", type: sap.ui.core.mvc.ViewType.JS });
var page1 = sap.ui.view({ id: "idEMainPage1", viewName: "empcrud.MainPage", type: sap.ui.core.mvc.ViewType.JS });
var page2 = sap.ui.view({ id: "idGrafPage1", viewName: "empcrud.Grafik", type: sap.ui.core.mvc.ViewType.JS });
app.addPage(page).addPage(page1).addPage(page2);
app.placeAt("content");
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content"></div>
</body>
</html>
And here is my view code where I use sap.viz.ui5 这是我使用sap.viz.ui5的视图代码
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions: [
{
axis: 1,
name: 'Uname',
value: "{Uname}"
}
],
measures: [
{
name: 'Modno',
value: '{Modno}'
},
],
data: {
path: "/results"
}
});
var oBarChart = new sap.viz.ui5.Bar({
width: "80%",
height: "400px",
plotArea: {
//'colorPalette' : d3.scale.category20().range()
},
title: {
visible: true,
text: 'Modno Grafiği'
},
dataset: oDataset
});
When I try to paste my view code in html script its works fine, also with xml view it works. 当我尝试将我的视图代码粘贴到html脚本中时,它可以很好地工作,对于xml视图,它也可以工作。 I think its about the connection between js view and html. 我认为它与js视图和html之间的连接有关。 However view can not see sap.viz.Is there a way to define sap.viz in js or how can I overcome that? 但是视图看不到sap.viz。是否可以在js中定义sap.viz或如何克服?
Thanks. 谢谢。
The problem is about sapui lib, just add online core library and just works fine. 问题是关于sapui库,只需添加在线核心库就可以了。 " https://sapui5.hana.ondemand.com/resources/sap-ui-core.js " “ https://sapui5.hana.ondemand.com/resources/sap-ui-core.js ”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.