blob: 7e1f9ef24fc412a4670df50332dbf45468855cac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---
title: Notification.body
slug: Web/API/notification/body
translation_of: Web/API/Notification/body
---
<p>{{APIRef("Web Notifications")}}</p>
<p> {{domxref("Notification")}} 的只读属性body返回了构造函数{{domxref("Notification")}}实例化时,options所使用的body值。</p>
<p>{{AvailableInWorkers}}</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="eval">var body = Notification.body;
</pre>
<h3 id="Return_Value" name="Return_Value">值</h3>
<p>{{domxref("DOMString")}}.</p>
<h2 id="示例">示例</h2>
<p>在 <a href="https://mdn.github.io/emogotchi/">Emogotchi demo</a> (<a href="https://github.com/mdn/emogotchi">see source code</a>)中, 我们在激活一个桌面通知时,调用了<code>spawnNotification()</code>函数—函数被传入了指定的参数 body、icon、title , 创建了一个必选对象传入{{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="规范">规范</h2>
<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-body','body')}}</td>
<td>{{Spec2('Web Notifications')}}</td>
<td>Living standard</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
{{Compat("api.Notification.body")}}
<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>
|