简体   繁体   中英

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. Here is my html code

<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

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. I think its about the connection between js view and html. However view can not see sap.viz.Is there a way to define sap.viz in js or how can I overcome that?

Thanks.

The problem is about sapui lib, just add online core library and just works fine. " https://sapui5.hana.ondemand.com/resources/sap-ui-core.js "

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM