简体   繁体   中英

Uncaught TypeError: Cannot read property 'Label' of undefined in SAPUI5 Mobile App for cross platforms Android using PhoneGap

While developing application on SAPUI5 Mobile App for cross platforms Android using PhoneGap I am facing issue like:

faile:///android-asset/www/resources/sap-ui-core.js:Line 117: Uncaught TypeError: Cannot read property 'Label' of undefined.

My Code is like:

var lab=new sap.m.Label({text: "From :",width:"100px"});
var dat1= new sap.m.DateTimeInput("dt1",{placeholder:"mm/dd/yyyy",value:before,valueFormat : "MM/dd/yyyy",displayFormat : "MM/dd/yyyy"});
var hb= new sap.m.HBox({items:[lab,dat1]});

var lab1=new sap.m.Label({text: "To :",width:"100px"});
var dat2= new sap.m.DateTimeInput("dt2",{placeholder:"mm/dd/yyyy",value:today,valueFormat : "MM/dd/yyyy",displayFormat : "MM/dd/yyyy"});
var hb2 = new sap.m.HBox({items:[lab1,dat2]});

The not loading sap.m.Label, sap.m.Button....so on .

Could please suggest me to avoid this issue.

I have added sap-ui-core.js at myproject/assets/resources/

Thanks in Advance!

As mentioned in the comments the sap.m libraries were missing as resources and in the bootstrap. Keep in mind that sap-ui-core.js is only the starting point of the UI5 Framework but not the whole framework. Including only this file to your project is not sufficient.

Make sure that you always include all necessary files (Runtime Version) to your ressources. You can get the latest from the official OpenUI5 site. If you only need the sap.m controls you can use the stripped-down UI5 Runtime Mobile version.

A proper bootstrap could look like this:

<script
    id="sap-ui-bootstrap"
    src="path/to/resources/sap-ui-core.js"
    data-sap-ui-theme="sap_bluecrystal"
    data-sap-ui-libs="sap.m">

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