jQuery.sap.includeScript().then()在SCP SAPUI5应用中不起作用 [英] jQuery.sap.includeScript().then() not working in SCP SAPUI5 app
问题描述
我正试图在sapui5中包含googlemaps
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() { ... } )
当我在SAP Web-IDE试用版中运行时,此Promise可以正常工作,但是当我将其部署到hana Cloud平台时,此Promise无法正常工作:
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未捕获(承诺)TypeError:u.indexOf不是函数(…) sap.ushell.cloudServices.interceptor.InterceptService._invokeFilters @ InterceptService.js:1
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
jQuery.sap.includeScript @ InterceptService.js:1
onAfterRendering @ Worklist.controller.js:37
onAfterRendering @ Worklist.controller.js:37
产生此错误的
InterceptService.js
代码片段是
InterceptService.js
code fragment that produced this error is
{if(u.indexOf('/sap/fiori/../../')>0){u=u.replace('/sap/fiori/../../','/');}
我确实使用 HCP门户服务来生产HCP Fiori Launchpad平台.
I do use HCP Portal Service to produce HCP Fiori Launchpad Platform.
如何解决此问题?我做错了什么?
How to fix this? What I did wrong?
非常感谢!
推荐答案
这确实是InterceptorService
的问题,它不支持以对象作为第一个参数的includeScript
语法.
It is indeed issue of InterceptorService
, which does not support the syntax of includeScript
with object as first argument.
我已将解决方案的代码转发给 HCP门户服务的实施团队,该代码将在下一个版本中修复.
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() { ... } )
查看UI5如何实现: 查看全文