aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/notification/data
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/notification/data
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/notification/data')
-rw-r--r--files/zh-cn/web/api/notification/data/index.html165
1 files changed, 165 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/notification/data/index.html b/files/zh-cn/web/api/notification/data/index.html
new file mode 100644
index 0000000000..b7426d601e
--- /dev/null
+++ b/files/zh-cn/web/api/notification/data/index.html
@@ -0,0 +1,165 @@
+---
+title: Notification.data
+slug: Web/API/notification/data
+translation_of: Web/API/Notification/data
+---
+<p>{{APIRef("Web Notifications")}}</p>
+
+<p><code>data</code> 只读属性是 {{domxref("Notification")}} 的接口,当它作为构造函数的option可选项之一时,返回结构化的Notification的data数据。</p>
+
+<p>当你创建Notification时,notification使用的数据可以使任意类型。</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<p>附加语法糖:关于克隆对象的速度研究。</p>
+
+<p>https://dassur.ma/things/deep-copy/ </p>
+
+<p>博客作者认为目前(参考)最快的object克隆、复制方式。</p>
+
+<pre style="color: #f8f8f2; background-color: #272822;"><code class="language-js"><span style="color: #66d9ef;">function</span> <span style="color: #a6e22e;">structuralClone</span>(<span style="color: #a6e22e;">obj</span>) {
+ <span style="color: #66d9ef;">return</span> <span style="color: #66d9ef;">new</span> <span style="color: #a6e22e;">Notification</span>(<span style="color: #e6db74;">''</span>, {<span style="color: #a6e22e;">data</span><span style="color: #f92672;">:</span> <span style="color: #a6e22e;">obj</span>, <span style="color: #a6e22e;">silent</span><span style="color: #f92672;">:</span> <span style="color: #66d9ef;">true</span>}).<span style="color: #a6e22e;">data</span>;
+}</code></pre>
+
+<h2 id="Syntax" name="Syntax">Syntax 表达式</h2>
+
+<pre class="eval">var <em>data</em> = Notification.data;
+</pre>
+
+<h3 id="Return_Value" name="Return_Value">Value(返回值)</h3>
+
+<p>结构化的克隆数据</p>
+
+<h2 id="Examples_例子">Examples 例子</h2>
+
+<p>产生一个 notification; <code>简单的options</code> 作为构造参数, 将会触发以option为构造参数的 <code>Notification()</code> .</p>
+
+<pre class="brush: js">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.'</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Web Notifications','#dom-notification-data','data')}}</td>
+ <td>{{Spec2('Web Notifications')}}</td>
+ <td>Living standard</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<p>{{ CompatibilityTable() }}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome</th>
+ <th>Edge</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatChrome(44)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{CompatOpera(34)}}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ <tr>
+ <td>Available in workers</td>
+ <td>{{CompatChrome(44)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoDesktop("41.0")}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(34)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Secure contexts only</td>
+ <td>{{CompatChrome(62)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android Webview</th>
+ <th>Chrome for Android</th>
+ <th>Edge</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>Firefox OS</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{CompatChrome(44)}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{CompatOperaMobile(34)}}</td>
+ <td>{{ CompatNo() }}</td>
+ </tr>
+ <tr>
+ <td>Available in workers</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{CompatChrome(44)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatGeckoMobile(41.0)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOperaMobile(34)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ <tr>
+ <td>Secure contexts only</td>
+ <td>{{ CompatNo() }}</td>
+ <td>{{CompatChrome(62)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOperaMobile(49)}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API">Using the Notifications API</a></li>
+</ul>