草案
此页面不完整。
getType()
方法在
ClipboardItem
interface returns a
Promise
that resolves with a
Blob
of the requested
MIME 类型
or an error if the MIME type is not found.
var blob = clipboardItem.getType(type);
type
A
Promise
that resolves with a
Blob
对象。
DOMException
type
does not match a known
MIME 类型
.
TypeError
type
is not that of the
ClipboardItem
.
In the following example, we're returning all items on the clipboard via the
clipboard.read()
method. Then utilizing the
ClipboardItem.types
property to set the
getType()
argument and return the corresponding blob object.
async function getClipboardContents() {
try {
const clipboardItems = await navigator.clipboard.read();
for (const clipboardItem of clipboardItems) {
for (const type of clipboardItem.types) {
const blob = await clipboardItem.getType(type);
// we can now use blob here
}
}
} catch (err) {
console.error(err.name, err.message);
}
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
Clipboard API and events
The definition of 'ClipboardItem' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
getType
|
Chrome 66 | Edge ≤79 | Firefox No | IE No | Opera Yes | Safari No | WebView Android 66 | Chrome Android 66 | Firefox Android No | Opera Android Yes | Safari iOS No | Samsung Internet Android Yes |
完整支持
不支持
实验。期望将来行为有所改变。