diff options
Diffstat (limited to 'files/zh-cn/web/api/notification/icon/index.html')
-rw-r--r-- | files/zh-cn/web/api/notification/icon/index.html | 63 |
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> |