Notification.data
data
只读属性是 Notification
的接口,当它作为构造函数的option可选项之一时,返回结构化的Notification的data数据。
当你创建Notification时,notification使用的数据可以使任意类型。
Note: 此特性在 Web Worker 中可用。
附加语法糖:关于克隆对象的速度研究。
https://dassur.ma/things/deep-copy/
博客作者认为目前(参考)最快的object克隆、复制方式。
function structuralClone(obj) {
return new Notification('', {data: obj, silent: true}).data;
}
Syntax 表达式
var data = Notification.data;
Value(返回值)
结构化的克隆数据
Examples 例子
产生一个 notification; 简单的options
作为构造参数, 将会触发以option为构造参数的 Notification()
.
var options = {
body: 'Do you like my body?',
data: 'I like peas.'
}
var n = new Notification('Test notification',options);
n.data // should return 'I like peas.'
Specifications
Specification | Status | Comment |
---|---|---|
Notifications API data |
Living Standard | Living standard |
Browser compatibility
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 44 | (Yes) | 未实现 | 未实现 | 34 | 未实现 |
Available in workers | 44 | ? | 41.0 (41.0) | ? | 34 | ? |
Secure contexts only | 62 | ? | ? | ? | 49 | ? |
Feature | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|
Basic support | 未实现 | 44 | (Yes) | 未实现 | 未实现 | 未实现 | 34 | 未实现 |
Available in workers | 未实现 | 44 | ? | 41.0 (41.0) | ? | ? | 34 | ? |
Secure contexts only | 未实现 | 62 | ? | ? | ? | ? | 49 | ? |