Skip to Content
avatar image
Former Member

Type Error:sap.m is undefined

Hi Gurus,

getting error as sap.m is undefined when running below index.html file in eclipse.

Any help will be really appreciated.

<!DOCTYPE html>
<html>
<head>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
   <title>Stock Overview App</title>
   <script
    src="https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"
    id="sap-ui-bootstrap"
    data-sap-ui-libs="sap.m,sap.ui.commons"
	data-sap-ui-theme="sap_belize" 
	data-sap-ui-compatVersion="edge"
	data-sap-ui-preload="async"	
	data-sap-ui-resourceroots='{
	   "view":"./"
	    }'>
  </script>


<script>


sap.ui.localResources("view");
var app = new sap.m.App({initialPage:"idView1"});
var page = sap.ui.view({id:"idView1", viewName:"view.main", type:sap.ui.core.mvc.ViewType.XML});
app.addPage(page);
app.placeAt("content");
 </script>
</head>


<body class="sapUiBody" role="application">
	<div id="content"></div>
</body>
</html>
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Aug 19, 2017 at 11:56 AM
    -1

    Could be that by the time you run your script you don't have sap.m loaded.

    Try changing to this:

    data-sap-ui-preload="sync"
    
    Add comment
    10|10000 characters needed characters exceeded