blob: c70a7655bf36dedd97c7b745e0776f0a5e94e2f6 (
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
59
60
61
62
63
64
65
66
67
68
|
---
title: CustomEvent.detail
slug: Web/API/CustomEvent/detail
translation_of: Web/API/CustomEvent/detail
---
<p>{{APIRef("DOM")}}</p>
<p>接口 {{domxref("CustomEvent")}} 的只读属性 <code><strong>detail</strong></code> (详情)返回在初始化事件对象时传递过来的任何类型数据。</p>
<p>{{AvailableInWorkers}}</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox"> let myDetail = <em>customEventInstance.detail</em>;</pre>
<h3 id="Return_value">Return value</h3>
<p>事件对象初始化时传递的任何类型数据。</p>
<h2 id="Example">Example</h2>
<pre class="brush: js">// add an appropriate event listener
obj.addEventListener("cat", function(e) { process(e.detail) });
// create and dispatch the event
let event = new CustomEvent("cat", {
detail: {
hazcheeseburger: true
}
});
obj.dispatchEvent(event);
// Will return an object contaning the hazcheeseburger property
let myDetail = <em>event.detail</em>;
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table" style="height: 49px; width: 1000px;">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('DOM WHATWG','#dom-customeventinit-detail','detail')}}</td>
<td>{{Spec2('DOM WHATWG')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{Compat("api.CustomEvent.detail")}}</p>
<h2 id="See_also">See also</h2>
<ul>
<li>{{domxref("CustomEvent")}}</li>
</ul>
<p> </p>
|