Notification:body 屬性

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

注意:此功能在 Web Workers 中可用。

bodyNotification 介面的一個只讀屬性,用於指示通知的正文字串,該字串在 Notification() 建構函式的 body 選項中指定。

字串。

示例

js
function spawnNotification(theBody, theIcon, theTitle) {
  const options = {
    body: theBody,
    icon: theIcon,
  };
  const n = new Notification(theTitle, options);

  console.log(n.body);
}

規範

規範
Notifications API
# dom-notification-body

瀏覽器相容性

另見