ClipboardItem: thuộc tính presentationStyle

Khả dụng hạn chế

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Thuộc tính chỉ đọc presentationStyle của giao diện ClipboardItem trả về một chuỗi cho biết cách một mục nên được trình bày.

Ví dụ, trong một số ngữ cảnh, ảnh có thể được hiển thị nội tuyến, còn trong ngữ cảnh khác nó có thể được biểu diễn như một tệp đính kèm.

Giá trị

Một trong các giá trị "unspecified", "inline" hoặc "attachment".

Ví dụ

Trong ví dụ dưới đây, chúng ta trả về tất cả các mục trong clipboard thông qua phương thức clipboard.read(), rồi ghi log thuộc tính presentationStyle.

js
async function getClipboardContents() {
  try {
    const clipboardItems = await navigator.clipboard.read();

    for (const clipboardItem of clipboardItems) {
      console.log(clipboardItem.presentationStyle);
    }
  } catch (err) {
    console.error(err.name, err.message);
  }
}

Thông số kỹ thuật

Thông số kỹ thuật
Clipboard API and events
# dom-clipboarditem-presentationstyle

Tương thích trình duyệt

Xem thêm