How to avoid “Synchronous XMLHttpRequest on the main thread“ warning in UI5?

题意:"如何避免在 UI5 中出现“主线程上的同步 XMLHttpRequest”警告?"

问题背景:

I'm staring my UI5 with the following bootstrapping in index.js:

"我在 `index.js` 中使用以下引导程序启动我的 UI5:"

sap.ui.define([
    "sap/m/Shell",
    "sap/ui/core/ComponentContainer"
], (Core, Shell, ComponentContainer) => {
    "use strict";

    new Shell("", {
        app: new ComponentContainer("", {
            height: "100%",
            name: "webapp"
        }),
        appWidthLimited: false
    }).placeAt("content");
});

According to the UI5 documentation:

"根据 UI5 文档:"

Static dependencies are loaded in the dependency declaration array of the sap.ui.define call. These dependencies are always loaded in advance before executing the defined module.

Do I understand it correctly that in such case the modules will be always loaded in a synchronous way and there is no real way to avoid the «Synchronous XMLHttpRequest on the main thread» warning?

"我是否正确理解,在这种情况下,模块将始终以同步方式加载,并且没有真正的方法可以避免“主线程上的同步 XMLHttpRequest”警告?"

Can I, perhaps, just wrap new sap.m.Shell(sId?, mSettings?) with async/await?

"我是否可以仅仅用 async/await 将 `new sap.m.Shell(sId?, mSettings?)` 包裹起来?"

Update #1:

I've checked the loading with ?sap-ui-xx-nosync=warn and got the following results:

"我使用 `?sap-ui-xx-nosync=warn` 检查了加载情况,并得到了以下结果:"

For some reason i18n/i18n_en.properties is loaded synchronously. The only place where I'm accessing the i18n is:

"出于某种原因,`i18n/i18n_en.properties` 是同步加载的。我访问 `i18n` 的唯一地方是:"

const oBundle = myI18nModel.getResourceBundle();

But following the documentation, I could not grasp why myI18nModel.getResourceBundle() leads to the synchronous loading.

"但是根据文档,我无法理解为什么 `myI18nModel.getResourceBundle()` 会导致同步加载。"

Update #2:

After a deep exploration of no sync XHR sample, I found out the reason for the sync XHR warning. That was "description": "{ {appDescription}}" and "title": "{ {appTitle}}" in manifest.json which is explicitly noted:

"经过对无同步 XHR 示例的深入探讨,我发现了同步 XHR 警告的原因。那是 `manifest.json` 中的 `"description": "{ {appDescription}}"` 和 `"title": "{ {appTitle}}"`,文档中明确指出:"

"title": "Here the i18n bundles can't be loaded with 'async: true' yet!",
"description": "Same here. Hence, no 'i18n' in this 'sap
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值