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

View in English Always switch to English

Notification:vibrate 属性

Deprecated

Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.

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

实验性: 这是一项实验性技术
在将其用于生产之前,请仔细检查浏览器兼容性表格。

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

Notification 接口的 vibrate 只读属性指定当通知触发时设备振动硬件发出的振动模式。此属性通过 Notification() 构造函数的 vibrate 选项指定。

值

一个振动 API 规范所指定的振动模式。

示例

以下代码片段旨在创建同时触发设备振动的通知;首先创建一个简单的 options 对象,然后使用 Notification() 构造函数触发通知。

js
const options = {
  body: "你提交的代码收到了 3 条新的审阅意见。",
  vibrate: [200, 100, 200],
};

const n = new Notification("新的评论活动", options);

console.log(n.vibrate); // [200, 100, 200]

规范

此特性似乎未在任何规范中定义。

浏览器兼容性

参见