Blob() constructor returns a new Blob object. The content of the blob consists of the concatenation of the values given in the parameter array .

句法

var newBlob = new Blob(array, options);
					

参数

array
数组 of ArrayBuffer , ArrayBufferView , Blob , USVString objects, or a mix of any of such objects, that will be put inside the Blob . USVString objects are encoded as UTF-8.
选项 可选

An optional object of type BlobPropertyBag which may specify any of the following properties:

type 可选
MIME 类型 of the data that will be stored into the blob. The default value is the empty string, ( "" ).
endings 可选
How to interpret newline characters ( \n ) within the contents, if the data is text. The default value, transparent , copies newline characters into the blob without changing them. To convert newlines to the host system's native convention, specify the value native .

返回值

新的 Blob object containing the specified data.

范例

var aFileParts = ['<a id="a"><b id="b">hey!</b></a>']; // an array consisting of a single DOMString
var oMyBlob = new Blob(aFileParts, {type : 'text/html'}); // the blob
					

规范

规范 状态 注释
文件 API
The definition of 'Blob()' 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
Blob() 构造函数 Chrome 20 Edge 12 Firefox 13
13
Before Firefox 16, the second parameter, when set to null or undefined , leads to an error instead of being handled as an empty dictionary.
IE 10 Opera 12 Safari 8 WebView Android 37 Chrome Android 25 Firefox Android 14
14
Before Firefox 16, the second parameter, when set to null or undefined , leads to an error instead of being handled as an empty dictionary.
Opera Android 12 Safari iOS 8 Samsung Internet Android 1.5

图例

完整支持

完整支持

见实现注意事项。

另请参阅

  • The deprecated BlobBuilder interface which this constructor replaces.

元数据

  • 最后修改: