Notification: data 屬性
注意:此功能在 Web Workers 中可用。
data 是 Notification 介面的一個只讀屬性,它返回一個對通知資料的結構化克隆,該資料是在 Notification() 建構函式的 data 選項中指定的。
通知的資料可以是您希望與通知關聯的任何任意資料。
值
一個結構化克隆。
示例
以下程式碼片段會觸發一個通知;建立一個簡單的 options 物件,然後使用 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); // Logs the data object
規範
| 規範 |
|---|
| Notifications API # dom-notification-data |
瀏覽器相容性
載入中…