【发布时间】:2021-01-07 05:11:27
【问题描述】:
我正在尝试在 sapui5 中包含 googlemaps
jQuery.sap.includeScript({
url: "https://maps.googleapis.com/maps/api/js?key=XXXX",
promisify: true
}).then(function() { ... } )
当我在 SAP Web-IDE Trial 中运行时,这个 Promise 工作正常,但是当我将它部署到 hana 云平台时,它不起作用:
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 产生此错误的代码片段是
{if(u.indexOf('/sap/fiori/../../')>0){u=u.replace('/sap/fiori/../../','/');}
我确实使用 HCP 门户服务 来制作 HCP Fiori Launchpad 平台。
如何解决这个问题?我做错了什么?
非常感谢!
【问题讨论】:
-
你不需要传递
promisify: true,因为它被UI5忽略了 -
根据经验,您仍然需要使用回调“当 API 准备就绪时,它将调用使用回调参数指定的函数。” developers.google.com/maps/documentation/javascript/tutorial
-
谢谢@Jasper_07 这两种方法我都试过了。但是我使用的是xml视图,所以使用google推荐的方式不太方便(我不知道如何将init函数放在另一个模块中)。而且我没有看到使用 openui5-googlemaps 的必要性......我已经受够了 xml 视图。
标签: sapui5 sap-fiori sap-cloud-platform