aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/console/clear/index.html
blob: 3e0f2ee470ff64cd491901a6adc3d9b899c827c4 (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
---
title: clear()
slug: Web/API/Console/clear
translation_of: Web/API/Console/clear
---
<div>{{APIRef("Console API")}}{{Non-standard_header}}</div>

<p>清空控制台.</p>

<p>控制台显示的内容将会被一些信息替换,比如‘Console was cleared’这样的信息。</p>

<p>需要的注意的一点是在Google Chrome浏览器中,如果用户在<a href="https://developers.google.cn/web/tools/chrome-devtools/console#preserve-log">设置</a>中勾选了“Preserve log”选项,console.clear()将不会起作用。 </p>

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

<pre class="syntaxbox">console.clear();
</pre>

<h2 id="规范">规范</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", "#consoleclear", "console.clear()")}}</td>
   <td>{{Spec2("Console API")}}</td>
   <td>Initial definition</td>
  </tr>
 </tbody>
</table>

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

{{Compat("api.console.clear")}}

<h2 id="相关链接">相关链接</h2>

<ul>
 <li><a href="http://www.opera.com/dragonfly/documentation/console/">Opera Dragonfly documentation: Console</a></li>
 <li><a href="http://msdn.microsoft.com/library/gg589530">MSDN: Using the F12 Tools Console to View Errors and Status</a></li>
 <li><a href="https://developer.chrome.com/devtools/docs/console#assertions">Chrome Developer Tools: Using the Console</a></li>
</ul>