gpt4 book ai didi

sapui5 - 如何更快地加载 sap.ui.comp.smarttable.SmartTable?

转载 作者:行者123 更新时间:2023-12-04 01:57:02 26 4
gpt4 key购买 nike

在 SAPUI5 中,当您第一次将 sap.m.DatePicker 添加到您的应用程序时,需要几秒钟时间来加载所需的文件并打开日期选择器。在API他们解释说:

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.

所以这就是他们建议的使 DatePicker 加载速度更快的解决方案。

当我使用 sap.ui.comp.smarttable.SmartTable 时,用户第一次看到该应用至少需要 10 到 15 秒。

实际上它会加载大量单独的 JavaScript 文件。这是加载的文件的一小部分。

Here is a small part of the files that are loaded.

现在的问题是,有什么办法可以加快加载速度吗?

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

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

最佳答案

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

  • “sap.ui.core”
  • “sap.m”
  • “sap.ui.comp”
  • “sap.ui.table” 其中,again, depends on ..
  • “sap.ui.unified”

这可以在 dependency list of the module 中看到.

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

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

  2. 并且在 app descriptor (manifest.json) ,声明依赖库启用preloading remote model data :

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

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

并且通过 preload: true,可以更早地请求 SmartTable 所依赖的服务 $metadata 文档和注释。


有关其他性能相关的最佳实践,请参阅 Performance Checklist .

关于sapui5 - 如何更快地加载 sap.ui.comp.smarttable.SmartTable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49817459/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com