我正在尝试在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代码片段是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
{if(u.indexOf('/sap/fiori/../../')>0){u=u.replace('/sap/fiori/../../','/');}
我确实使用HCP Portal Service生成HCP Fiori Launchpad平台。
如何解决?我做错了什么?非常感谢!
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
中期,InterceptService需要增强/修复。短期而言,您可能会退回到旧的签名jQuery.sap.includeScript(url, id, onload, onerror)。不幸的是,没有办法获得带有旧签名的承诺。