jQuery.sap.includeScript()。then()在SCP SAPUI5应用中不起作用

问题描述 投票:1回答:2

我正在尝试在sapui5中包含googlemaps

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

当我在SAP Web-IDE试用版中运行时,此Promise正常工作,但是当我将其部署到hana Cloud平台时,它不起作用:

InterceptService.js:1未捕获(承诺)TypeError:u.indexOf不是函数(…)sap.ushell.cloudServices.interceptor.InterceptService._invokeFilters @ InterceptService.js:1

jQuery.sap.includeScript @ InterceptService.js:1

onAfterRendering @ Worklist.controller.js:37

InterceptService.js代码片段是

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

我确实使用

HCP Portal Service生成HCP Fiori Launchpad平台。

如何解决?我做错了什么?

非常感谢!

sapui5 sap sap-fiori sap-cloud-platform
2个回答
2
投票
确实是InterceptorService的问题,它不支持以对象作为第一个参数的includeScript的语法。

我已将解决方案的代码转发给

HCP Portal Service的实现团队,它将在下一版本中修复。

到目前为止,您可以通过以下解决方法实现相同的功能:

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

请参阅UI5如何实现: https://github.com/SAP/openui5/blob/rel-1.38/src/sap.ui.core/src/jquery.sap.global.js#L4387-L4389


1
投票
类似InterceptService尚不支持jQuery.sap.includeScript的最新签名(其中,参数在配置对象中提供,而不是作为单独的参数提供)。

中期,InterceptService需要增强/修复。短期而言,您可能会退回到旧的签名jQuery.sap.includeScript(url, id, onload, onerror)。不幸的是,没有办法获得带有旧签名的承诺。

© www.soinside.com 2019 - 2024. All rights reserved.