Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
757 views
in Technique[技术] by (71.8m points)

sap fiori - jQuery.sap.includeScript().then() not working in SCP SAPUI5 app

I'm trying to include googlemaps in sapui5

jQuery.sap.includeScript({
                url: "https://maps.googleapis.com/maps/api/js?key=XXXX",
                promisify: true
            }).then(function() { ... } )

This Promise works fine when I run in SAP Web-IDE Trial, but when I deploy it to hana cloud platform it is not working:

InterceptService.js:1 Uncaught (in promise) TypeError: u.indexOf is not a function(…) sap.ushell.cloudServices.interceptor.InterceptService._invokeFilters @ InterceptService.js:1

jQuery.sap.includeScript @ InterceptService.js:1

onAfterRendering @ Worklist.controller.js:37

InterceptService.js code fragment that produced this error is

{if(u.indexOf('/sap/fiori/../../')>0){u=u.replace('/sap/fiori/../../','/');}

I do use HCP Portal Service to produce HCP Fiori Launchpad Platform.

How to fix this? What I did wrong?

Thanks a lot!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It is indeed issue of InterceptorService, which does not support the syntax of includeScript with object as first argument.

I've forwarded a code of the solution to implementation team of HCP Portal Service and it will be fixed in the next release.

So far, you can achieve the same functionality with the following workaround:

new Promise(function(fnResolve, fnReject) {
    jQuery.sap.includeScript(
        "https://maps.googleapis.com/maps/api/js?key=XXXX", 
        "mapsScriptId", fnResolve, fnReject
    );
}).then(function() { ... } )

See how UI5 implements it: https://github.com/SAP/openui5/blob/rel-1.38/src/sap.ui.core/src/jquery.sap.global.js#L4387-L4389


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...