FileReaderSync:FileReaderSync() 构造函数

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

备注: 此特性仅在 Web Worker(不包括 Service Worker)中可用。

FileReaderSync() 构造函数创建一个新的 FileReaderSync 对象。

语法

js
new FileReaderSync()

参数

无。

示例

以下代码片段显示了使用 FileReaderSync() 构造函数创建 FileReaderSync 对象以及该对象后续的用法:

js
function readFile(blob) {
  const reader = new FileReaderSync();
  postMessage(reader.readAsDataURL(blob));
}

备注: 此代码段必须在 Worker 内部使用,因为同步接口不能在主线程上使用。

规范

Specification
File API
# filereadersyncConstrctr

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
FileReaderSync() constructor

Legend

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

Full support
Full support
No support
No support