HTMLDwebBarcodeScanningElement
WebComponentHTMLDwebBarcodeScanningElement小于 1 分钟
HTMLDwebBarcodeScanningElement是一个实现扫码功能的 WebComponent元素;
继承与 HTMLElement;
<dweb-barcode-scanning></dweb-barcode-scanning>
属性
plugin
属性值是 BarcodeScannerPlugin
getView
属性值是 video 元素的父元素;
process
属性值是 BarcodeScannerPlugin.process()方法;
stop
属性只是 BarcodeScannerPlugin.stop() 方法;
方法
HTMLDwebBarcodeScanningElement.startScanning()
启动扫码程序
HTMLDwebBarcodeScanningElement.stopScanning()
停止扫码程序;
HTMLDwebBarcodeScanningElement.getSupportedFormats()
获取支持的格式;
事件
支持任意事件,无预定义事件;
示例
<body>
<dweb-barcode-scanning></dweb-barcode-scanning>
<button>scanner</button>
<script type="module">
import "@plaoc/plugins"
const barcodeScanner = document.querySelector("dweb-barcode-scanning")!
const btn = document.querySelector('button');
btn.addEventListener('click', async () => {
const res = await barcodeScanner.startScanning();
})
</script>
</body>
平台兼容性
属性/方法/事件 | Android | IOS | Desktop-Dev | Desktop |
---|---|---|---|---|
getView | ✅ | ✅ | ✅ | X |
process | ✅ | ✅ | ✅ | X |
stop | ✅ | ✅ | ✅ | X |
startScanning | ✅ | ✅ | ✅ | X |
stopScanning | ✅ | ✅ | ✅ | X |
getSupportedFormats | ✅ | ✅ | ✅ | X |
相关链接
Powered by Waline v2.15.7