如何将外部库加载到 SAPUI5 视图中? [英] how to load external libraries into an SAPUI5 view?

查看:36
本文介绍了如何将外部库加载到 SAPUI5 视图中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SAPUI5 中,我可以这样加载本地文件:

In SAPUI5 I can load local files this way:

jQuery.sap.require("util.someFile"); 

但是是否可以在某些视图中使用上述命令或类似方法在需要时加载外部库?理想情况下,我正在寻找类似的东西:

But is it possible to load external libraries when required in some view using the above command or a similar approach? Ideally, I am looking for something like:

theLoadingCommand("some_url"); 

谢谢

推荐答案

基本上可以将模块路径注册到某个 URL.

Basically it is possible to register a module path to some URL.

jQuery.sap.registerModulePath('external.library', 'http://....'); //not working

只有一个问题.UI5 通过 AJAX 请求加载资源.您的浏览器会报错,因为您正在尝试从不同的主机加载文件.

There is only one problem with that. UI5 loads the resources via AJAX requests. Your browser will give you an error because you are trying to load files from a different host.

您可以通过将文件包含在普通脚本标记中来包含外部库.也可以在您的项目中包含 requireJS 并使用其功能.不幸的是,目前 UI5 不支持开箱即用的 requireJS.

You can include external libraries by including the file in a normal script tag. It is also possible to include requireJS in your project and use its features. Unfortunately, at the moment UI5 doesn't support requireJS out of the box.

这篇关于如何将外部库加载到 SAPUI5 视图中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆