Notification: lang 属性
注意:此功能在 Web Workers 中可用。
Notification 接口中只读的 lang 属性表示通知中使用的语言,该语言是在 Notification() 构造函数的 lang 选项中指定的。
语言本身使用表示 BCP 47 语言标记 的字符串来指定。
值
指定语言标记的字符串。
示例
以下代码片段会触发一个通知;创建一个简单的 options 对象,然后使用 Notification() 构造函数触发通知。
js
const options = {
body: "Your code submission has received 3 new review comments.",
lang: "en-US",
};
const n = new Notification("New review activity", options);
console.log(n.lang); // "en-US"
规范
| 规范 |
|---|
| Notifications API # dom-notification-lang |
浏览器兼容性
加载中…