1. 面向开发者的 Web 技术
  2. Web API
  3. Notification
  4. Notification:data 属性

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Notification:data 属性

有限可用

此特性不属于基线,因为它尚未在主流浏览器中得到支持。

Want more support for this feature? Tell us why.

安全上下文: 此特性仅在一些支持的浏览器安全上下文(HTTPS)中可用。

备注: 此特性在 Web Worker 中可用。

Notification 接口的 data 只读属性根据 Notification() 构造函数的 data 选项返回一个通知数据的结构化克隆。

通知的数据可以是任何你想要与通知关联的任意数据。

一个结构化克隆的数据。

示例

以下代码段会触发一条通知。一个简单的 options 对象被创建,然后使用 Notification() 构造函数触发通知。

js
const options = {
 body: "你提交的代码收到了 3 条新的审阅意见。",
 data: {
 url: "https://example.com/review/12345",
 status: "open",
 },
};
const n = new Notification("新评论活动", options);
console.log(n.data); // 打印 data 对象

规范

规范
Notifications API
# dom-notification-data

浏览器兼容性

参见

帮助改进 MDN

了解如何参与贡献

此页面最后更新于 ,由 MDN 贡献者更新。

AltStyle によって変換されたページ (->オリジナル) /