aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/console/trace/index.html
blob: 682eba535ee67a7477889cff623e0dbe4dec05be (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
69
70
---
title: console.trace
slug: Web/API/Console/trace
translation_of: Web/API/Console/trace
---
<p>{{APIRef("Console API")}}</p>

<p>{{domxref("console")}} 的 <strong><code>trace()</code> 方法</strong>向 <a href="/zh-cn/Tools/Web_Console" title="Web Console">Web控制台</a> 输出一个堆栈跟踪。</p>

<p>{{AvailableInWorkers}}</p>

<p>在页面{{ domxref("console") }}文档中查看<a href="/zh-CN/docs/Web/API/console#堆栈跟踪" title="zh-cn/DOM/console#Stack_traces">堆栈跟踪</a>的详细介绍和示例。</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="notranslate">console.trace( [...<var>any</var>, ...<var>data</var> ]);</pre>

<h3 id="参数">参数</h3>

<dl>
 <dt><code>...<var>any</var>, ...<var>data</var></code> {{optional_inline}}</dt>
 <dd>Zero or more objects to be output to console along with the trace. These are assembled and formatted the same way they would be if passed to the {{domxref("console.log()")}} method.</dd>
</dl>

<h2 id="Syntax" name="Syntax">Example</h2>

<pre class="notranslate">function foo() {
  function bar() {
    console.trace();
  }
  bar();
}

foo();
</pre>

<p>In the console, the following trace will be displayed:</p>

<pre class="notranslate">bar
foo
&lt;anonymous&gt;</pre>

<h2 id="Specification" name="Specification">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName("Console API", "#trace", "console.trace()")}}</td>
   <td>{{Spec2("Console API")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<p>{{Compat("api.Console.trace")}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="http://www.opera.com/dragonfly/documentation/console/">Opera Dragonfly documentation: Console</a></li>
</ul>