如何在后台加载sapui5资源 [英] How to load sapui5 resources in the background

查看:35
本文介绍了如何在后台加载sapui5资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的应用程序中,我们加载了许多 SAPUI5 库.index.html 有如下代码加载 SAPUI5 资源

In our application we load a number of SAPUI5 libraries. index.html has the following code to load the SAPUI5 resources

<script src="resources/sap-ui-cachebuster/sap-ui-core.js"
        id="sap-ui-bootstrap"
        data-sap-ui-libs="sap.ui.commons,sap.ui.table,sap.ui.ux3,sap.m"
        data-sap-ui-theme="sap_bluecrystal" 
        data-sap-ui-appCacheBuster="./">

</script>

在我们的 web.xml 中,我们提到了 https://sapui5.hana.ondemand.comcom.sap.ui5.resource.REMOTE_LOCATION 加载资源.

In our web.xml we have mentioned https://sapui5.hana.ondemand.com as the com.sap.ui5.resource.REMOTE_LOCATION to load the resources.

我们观察到的是,应用程序首次加载需要很长时间.并且网络调用给出了加载 UI5 资源需要最长时间的想法.有没有办法可以更快地加载 UI5 资源?还是在后台?建议或代码示例在这里真的很有帮助.谢谢.

What we are observing is that the application takes a very long time to load for the first time. And network calls give an idea that loading of UI5 resources takes maximum time. Is there a way we can load the UI5 resources faster? or in the background? An advice or a code sample will really be helpful here. Thanks.

推荐答案

您可以加载 UI5 资源 异步.使用 data-sap-ui-preload="async"

You can load UI5 resources asynchronously. Use data-sap-ui-preload="async"

<script src="resources/sap-ui-cachebuster/sap-ui-core.js" id="sap-ui-bootstrap"
         data-sap-ui-libs="sap.ui.commons,sap.ui.table,sap.ui.ux3,sap.m"
         data-sap-ui-theme="sap_bluecrystal" 
         data-sap-ui-preload="async"
         data-sap-ui-appCacheBuster="./">

但是您必须使用 attachInitEvent 方法来延迟对 SAPUI5 API 的访问

But you must delay the access to the SAPUI5 APIs by using the attachInitEvent method

var oCore = sap.ui.getCore();
oCore.attachInit(function() {
    //do the needful
});

这篇关于如何在后台加载sapui5资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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