如何更快地加载 sap.ui.comp.smarttable.SmartTable? [英] How to load sap.ui.comp.smarttable.SmartTable faster?

查看:19
本文介绍了如何更快地加载 sap.ui.comp.smarttable.SmartTable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SAPUI5 中,当您第一次向应用添加 sap.m.DatePicker 时,加载所需文件并打开日期选择器需要几秒钟的时间.在

现在的问题是,有没有办法让加载速度更快?

我在 manifest 的 dependencies 中尝试了以下代码,但没有帮助.

"sap.ui.comp": {minVersion":1.52.1"}

解决方案

SmartTable 是一个巨大的控件,它依赖于以下库:

这可以在模块依赖列表.

尝试预先异步预加载这些库:

  1. 如果您可以控制引导程序配置,请添加 data-sap-ui-async=true"(或 data-sap-ui-preload=async"; 如果 UI5 版本 <1.58.2).

  2. 并且在 应用描述符 (manifest.json),声明依赖库启用预加载远程模型数据:

    {...sap.ui5":{依赖关系":{库":{"sap.ui.core": {},"sap.m": {},"sap.ui.comp": {},"sap.ui.table": {},sap.ui.unified":{}},},楷模": {myODataModel":{预加载":真,...

这应该会更快地加载表格,因为它的依赖项不再需要按需和同步加载,从而避免冻结浏览器的 UI 线程.

并且使用 preload: true,可以更早地请求服务 $metadata 文档和注释,而 SmartTable 依赖于此.


有关其他与性能相关的最佳做法,请参阅性能清单.

In SAPUI5 when you add a sap.m.DatePicker to your app for the first time it takes some seconds to load the required files and open the date picker. In the API they explained:

Note: The sap.ui.unified.Calendar is used internally only if the DatePicker is opened (not used for the initial rendering). If the sap.ui.unified library is not loaded before the DatePicker is opened, it will be loaded upon opening. This could lead to a waiting time when the DatePicker is opened for the first time. To prevent this, apps using the DatePicker should also load the sap.ui.unified library.

So this it the solution they suggest for making the loading of DatePicker faster.

When I use sap.ui.comp.smarttable.SmartTable it takes at least 10 to 15 seconds for the first time that user can see the app.

Actually it loads a huge number of individuals JavaScript files. Here is a small part of the files that are loaded.

Now the question is, Is there anyway to make this loading faster?

I tried the following code in the dependencies of manifest but was not helpful.

"sap.ui.comp": {
    "minVersion": "1.52.1"
}

解决方案

SmartTable is a huge control that has dependencies to the following libraries:

  • "sap.ui.core"
  • "sap.m"
  • "sap.ui.comp"
  • "sap.ui.table" which, again, depends on ..
  • "sap.ui.unified"

This can be seen in the dependency list of the module.

Try preloading those libraries beforehand asynchronously:

  1. If you can control the bootstrap config, add data-sap-ui-async="true" (or data-sap-ui-preload="async" if UI5 version < 1.58.2).

  2. And in the app descriptor (manifest.json), declare the dependent libs and enable preloading remote model data:

    {
      ...
      "sap.ui5": {
        "dependencies": {
          "libs": {
            "sap.ui.core": {},
            "sap.m": {},
            "sap.ui.comp": {},
            "sap.ui.table": {},
            "sap.ui.unified": {}
          },
        },
        "models": {
          "myODataModel": {
            "preload": true,
            ...

This should load the table faster since its dependencies don't need to be loaded on-demand and synchronously anymore which avoids freezing the UI thread of the browser.

And with the preload: true, the service $metadata document and annotations can be requested earlier on which the SmartTable depends.


For other performance related best-practices, see Performance Checklist.

这篇关于如何更快地加载 sap.ui.comp.smarttable.SmartTable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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