Web Notificationsservice
NotificationEvent() 构造函数创建一个新的 NotificationEvent 对象。
语法
new NotificationEvent(type, options)
参数
type- : 一个表示事件名称的字符串。它区分大小写,浏览器使用时将其设置为
notificationclick或notificationclose。
- : 一个表示事件名称的字符串。它区分大小写,浏览器使用时将其设置为
options- : 一个对象,除了 ExtendableEvent/ExtendableEvent 中定义的属性外,还具有以下属性:
notification- : 一个 Notification 对象,用作触发事件的通知。
action- : 一个与通知关联的操作。默认为
""。
- : 一个与通知关联的操作。默认为
- : 一个对象,除了 ExtendableEvent/ExtendableEvent 中定义的属性外,还具有以下属性:
返回值
一个新的 NotificationEvent() 对象。
示例
const n = new Notification("Hello");
const myNotificationEvent = new NotificationEvent(type, { notification: n });
规范
浏览器兼容性
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
