BarcodeDetector:getSupportedFormats() 静态方法

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

安全上下文: 此项功能仅在一些支持的浏览器安全上下文(HTTPS)中可用。

备注: 此特性在 Web Worker 中可用。

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格

BarcodeDetector 接口的 getSupportedFormats() 静态方法返回一个 Promise,它兑现一个包含受支持的条形码格式类型的数组

语法

js
BarcodeDetector.getSupportedFormats()

参数

无。

返回值

一个 Promise,它兑现一个包含受支持的条形码格式类型数组

异常

不会抛出任何异常。

示例

以下示例调用 getSupportedFormats() 方法并将结果记录到控制台。

js
// 检查支持的类型
BarcodeDetector.getSupportedFormats().then((supportedFormats) => {
  supportedFormats.forEach((format) => console.log(format));
});

规范

Specification
Accelerated Shape Detection in Images
# dom-barcodedetector-getsupportedformats

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getSupportedFormats() static method
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.
User must explicitly enable this feature.
Has more compatibility info.