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 |
浏览器兼容性
加载中…