aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/notification/icon
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/icon
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/icon')
-rw-r--r--files/zh-cn/web/api/notification/icon/index.html63
1 files changed, 63 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/notification/icon/index.html b/files/zh-cn/web/api/notification/icon/index.html
new file mode 100644
index 0000000000..40f76c90f0
--- /dev/null
+++ b/files/zh-cn/web/api/notification/icon/index.html
@@ -0,0 +1,63 @@
+---
+title: Notification.icon
+slug: Web/API/notification/icon
+tags:
+ - API
+ - Notification
+translation_of: Web/API/Notification/icon
+---
+<p>{{APIRef("Web Notifications")}}</p>
+
+<p>{{domxref("Notification")}}的只读属性<strong>icon</strong>使得包含<code>icon</code>的 URL 被显示成通知的一部分,如同指定{{domxref("Notification.Notification","Notification()")}}构造函数中<code>icon</code>的属性。</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="eval">var icon = Notification.icon;
+</pre>
+
+<h3 id="Return_Value" name="Return_Value">值</h3>
+
+<p>一个 {{domxref("USVString")}}。</p>
+
+<h2 id="示例">示例</h2>
+
+<p>在此<a href="https://github.com/mdn/emogotchi">示例</a>中,当我们想要发出一个通知时,我们运行一个简单的 <code>spawnNotification() 函数</code>——这是传递参数来指定我们想要的主体、图标和标题,然后它创建必要的<code>options</code>对象,并使用{{domxref("Notification.Notification","Notification()")}}构造函数来触发通知。</p>
+
+<pre class="brush: js">function spawnNotification(theBody,theIcon,theTitle) {
+ var options = {
+ body: theBody,
+ icon: theIcon
+ }
+ var n = new Notification(theTitle,options);
+}</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-icon','icon')}}</td>
+ <td>{{Spec2('Web Notifications')}}</td>
+ <td>Living standard</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+
+
+<p>{{Compat("api.Notification.icon")}}</p>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li><a href="/en-US/docs/Web/API/Notifications_API/Using_the_Notifications_API">Using the Notifications API</a></li>
+</ul>