arrayBuffer() 方法在 Blob interface returns a Promise that resolves with the contents of the blob as binary data contained in an ArrayBuffer .

句法

var bufferPromise = blob.arrayBuffer();
blob.arrayBuffer().then(buffer => /* process the ArrayBuffer */);
var buffer = await blob.arrayBuffer();
					

参数

None.

返回

A promise that resolves with an ArrayBuffer that contains the blob's data in binary form.

异常

While this method doesn't throw exceptions, it may reject the promise. This can happen, for example, if the reader used to fetch the blob's data throws an exception. Any exceptions thrown while getting the data will be converted into rejections.

用法注意事项

While similar to the FileReader.readAsArrayBuffer() 方法, arrayBuffer() returns a promise rather than being an event-based API, as is the case with the FileReader interface's method.

规范

规范 状态 注释
文件 API
The definition of 'Blob.arrayBuffer()' in that specification.
工作草案

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
arrayBuffer() Chrome 76 Edge 79 Firefox 69 IE No Opera No Safari No WebView Android 76 Chrome Android 76 Firefox Android No Opera Android 54 Safari iOS No Samsung Internet Android 12.0

图例

完整支持

完整支持

不支持

不支持

另请参阅

元数据

  • 最后修改:
  1. Blob
  2. 构造函数
    1. Blob()
  3. 特性
    1. size
    2. type
  4. 方法
    1. arrayBuffer()
    2. slice()
    3. stream()
    4. text()
  5. 文件 API 相关页面
    1. File
    2. FileList
    3. FileReader
    4. FileReaderSync