我正在尝试在我的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.
发布评论
评论(1)
The
manifest.json
section/sap.ui5/resources/
相反,请查看现有的解决方案:
sap.ndc.barcodescanner(button)
支持纯SAPUI5 Web应用程序(无杂交)与早期版本不同。 https://ui5.sap.com/#/entity/sap.ndc.barcodescannerbutton/sample/sample/sap.sample.sample.barcodescannerbuttonSAP/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:
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.BarcodeScannerButtonsap/ui/webc/fiori/BarcodeScannerDialog
control.Both standard UI5 controls
sap/ndc/BarcodeScanner
andsap/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