UI5应用中的第三方LIB仅在刷新后加载

发布于 2025-02-04 01:44:43 字数 1092 浏览 2 评论 0 原文

我正在尝试在我的UI5项目中实现Zxing条形码扫描仪库。为此,我要遵循以下教程: https://blogs.sap.com/2021/02/01/native-js-zxing-scanner-in-sapui5/

到目前为止,它运行良好。现在,我发现外部库在第一个应用程序开放中没有加载。因此,如果我以隐身模式打开UI5 lib,则库未加载,我会收到以下错误:

找不到变量:zxing

在附加页面后重新加载后,LIB成功加载并有效。

我的 mainfest.json 内的资源部分:

"resources": {
  "css": [
    {
      "uri": "css/style.css"
    }
  ],
  "js": [
    {
      "uri": "libs/zxing.min.js"
    }
  ]
}

然后,我在“ WebApp/controls/barcodescanner”下的自定义控件内使用 zxing (如所说的教程中所述)和我已经用/ *全局zxing注释了该文件:true */

然后在 master.controller.js#init 中,我初始化扫描仪:

this.oScanner = new BarcodeScanner({
  valueScanned: [this.onScanned, this],
  decoderKey: 'text',
});

我完全迷失了。为什么库不在首页视图中加载?但是从图书馆的第一个刷新起,毫无问题。这只是第一个负载。那是一个愚蠢的问题,我无法找到解决方案。

I'm trying to implement the ZXing barcode scanner library inside my UI5 project. For this I'm following the following tutorial: https://blogs.sap.com/2021/02/01/native-js-zxing-scanner-in-sapui5/.

So far it works pretty well. Now I've discovered that the external library doesn't load at the first app opening. So if I open the UI5 lib in incognito mode, the library isn't loaded and I get the following error:

Can't find variable: ZXing

After an additional page reload the lib is successfully loaded and works.

The resources section inside my mainfest.json:

"resources": {
  "css": [
    {
      "uri": "css/style.css"
    }
  ],
  "js": [
    {
      "uri": "libs/zxing.min.js"
    }
  ]
}

I'm then using the ZXing inside the custom control under "webapp/controls/BarcodeScanner" (as in the tutorial stated) and I have annotated the file with /* global ZXing:true */.

Then inside the Master.controller.js#init, I initialize the scanner:

this.oScanner = new BarcodeScanner({
  valueScanned: [this.onScanned, this],
  decoderKey: 'text',
});

I'm completely lost. Why doesn't the library get loaded at the first page view? But from the first refresh on the library works without problems. It's just the first load. That's such a dumb problem and I can't get the solution for.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光沙漏 2025-02-11 01:44:45

The manifest.json section /sap.ui5/resources/

相反,请查看现有的解决方案:

  1. 如果应用程序正在使用SAPUI5 1.84.18或更高版本运行,只需使用 sap.ndc.barcodescanner(button)支持纯SAPUI5 Web应用程序(无杂交)与早期版本不同。 https://ui5.sap.com/#/entity/sap.ndc.barcodescannerbutton/sample/sample/sap.sample.sample.barcodescannerbutton
  2. 如果该应用程序使用OpenUI5:
    • 尝试(实验) 控制。
    • 该应用在Android或MacOS上的基于铬的浏览器中运行(iOS尚不支持**),请尝试使用Web标准 Shape检测API ,该API ,该API 支持原始检测条形码。这是一个带有形状检测API的OpenUI5样品:

SAP/NDC/BARCODESCANNER 和 sap/ui/webc/fiori/barcodescannerdialog 内部实现zxing。


*参见注2992772

**请求WebKit中的形状检测API实现: https://bugs.webkit。 org/show_bug.cgi?id = 198174

The manifest.json section /sap.ui5/resources/js is deprecated since UI5 1.94.

Instead, have a look at the existing solutions:

  1. If the app is running with SAPUI5 1.84.18 or higher, simply use sap.ndc.BarcodeScanner(Button) which supports pure SAPUI5 web apps (no hybrid) unlike in earlier versions.* Sample: https://ui5.sap.com/#/entity/sap.ndc.BarcodeScannerButton/sample/sap.ndc.sample.BarcodeScannerButton
  2. If the app is running with OpenUI5:

Both standard UI5 controls sap/ndc/BarcodeScanner and sap/ui/webc/fiori/BarcodeScannerDialog implement ZXing internally.


* See Note 2992772.
** Request for the Shape Detection API implementation in WebKit: https://bugs.webkit.org/show_bug.cgi?id=198174

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文