BarcodeScannerButton 现在支持浏览器上使用,不过有版本要求,见下面的note:https://launchpad.support.sap.com/#/notes/2992772
我是在1.71.41下面去尝试了下,发现是可以在浏览器上使用这个控件的。这也是官方推荐的使用方案之一。后面官方推荐的开源库 Quagga.js 和 ZXing.js 我在后面也会逐一去尝试,对比一下优劣。OK ,不多说,上代码。
view里面增加控件
<App>
<pages>
<Page title="{i18n>title}">
<ndc:BarcodeScannerButton scanSuccess="onScanSuccess">
</ndc:BarcodeScannerButton>
</Page>
</pages>
</App>
在controller 里面实现扫描成功的方法 onScanSuccess
onScanSuccess: function(oEvent) {
MessageToast.show(oEvent.getParameters().text);
}
最后想说的是,干了这么多年活,还是要不忘初心,寻找Best Practice。最近是有点迷失了hh