Notification: thuộc tính data

Limited availability

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.

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc data của giao diện Notification trả về một bản sao cấu trúc của dữ liệu thông báo, như được chỉ định trong tùy chọn data của constructor Notification().

Dữ liệu của thông báo có thể là bất kỳ dữ liệu tùy ý nào mà bạn muốn gắn với thông báo.

Giá trị

Một bản sao cấu trúc.

Ví dụ

Đoạn mã sau phát một thông báo; một object options đơn giản được tạo rồi thông báo được phát bằng constructor Notification().

js
const options = {
  body: "Your code submission has received 3 new review comments.",
  data: {
    url: "https://example.com/review/12345",
    status: "open",
  },
};

const n = new Notification("New review activity", options);

console.log(n.data); // Ghi ra object dữ liệu

Thông số kỹ thuật

Specification
Notifications API
# dom-notification-data

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

Xem thêm