Blob
接口的
slice()
method creates and returns a new
Blob
object which contains data from a subset of the blob on which it's called.
var newBlob = blob.slice(start, end, contentType);
start
可选
Blob
indicating the first byte to include in the new
Blob
. If you specify a negative value, it's treated as an offset from the end of the
Blob
toward the beginning. For example, -10 would be the 10th from last byte in the
Blob
. The default value is 0. If you specify a value for
start
that is larger than the size of the source
Blob
, the returned
Blob
has size 0 and contains no data.
end
可选
Blob
indicating the first byte that will *not* be included in the new
Blob
(i.e. the byte exactly at this index is not included). If you specify a negative value, it's treated as an offset from the end of the
Blob
toward the beginning. For example, -10 would be the 10th from last byte in the
Blob
。默认值为
size
.
contentType
可选
Blob
; this will be the value of its
type
property. The default value is an empty string.
新的
Blob
object containing the specified subset of the data contained within the blob on which this method was called. The original blob is not altered.
| 规范 | 状态 | 注释 |
|---|---|---|
|
文件 API
The definition of 'Blob.slice()' 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 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
slice()
|
Chrome
21
|
Edge 12 |
Firefox
13
|
IE 10 | Opera 12 |
Safari
5.1
Prefixed
|
WebView Android Yes |
Chrome Android
25
|
Firefox Android 14 | Opera Android Yes | Safari iOS Yes |
Samsung Internet Android
1.5
|
完整支持
见实现注意事项。
要求使用供应商前缀或不同名称。
Blob
arrayBuffer()
slice()
stream()
text()