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

View in English Always switch to English

notifications.TemplateType

这是表示要创建的通知类型的字符串。有四种通知类型:“basic”、“image”、“list”、“progress”。

这将作为 NotificationOptions 中的 type 属性的值传递给 notifications.create() 和 notifications.update()。

类型

该类型的取值是字符串。可能的取值包括:

  • "basic":通知包括:

    • 标题(NotificationOptions.title)
    • 消息(NotificationOptions.message)
    • 图标(NotificationOptions.iconUrl)可选
    • 额外消息(NotificationOptions.contextMessage)可选
    • 最多两个按钮(NotificationOptions.buttons)可选
  • "image":包括 "basic" 中的所有内容,以及:

    • 图像(NotificationOptions.imageUrl)
  • "list":包括 "basic" 中的所有内容,以及:

    • 项目列表(NotificationOptions.items)
  • "progress":包括 "basic" 中的所有内容,以及:

    • 进度条(NotificationOptions.progress)

目前 Firefox 仅支持“basic”。

浏览器兼容性

备注:此 API 基于 Chromium 的 chrome.notifications API。