aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/window/console/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/window/console/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/window/console/index.html')
-rw-r--r--files/zh-cn/web/api/window/console/index.html49
1 files changed, 49 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/window/console/index.html b/files/zh-cn/web/api/window/console/index.html
new file mode 100644
index 0000000000..3e00d38643
--- /dev/null
+++ b/files/zh-cn/web/api/window/console/index.html
@@ -0,0 +1,49 @@
+---
+title: Window.console
+slug: Web/API/Window/console
+translation_of: Web/API/Window/console
+---
+<p>{{ APIRef }}</p>
+
+<p>只读属性Window.console返回一个对{{domxref("Console")}}对象的引用,Window.console提供了向浏览器控制台输出日志信息的方法。这些方法仅应该用于调试,并不应该用来给最终用户呈现信息。</p>
+
+<h2 id="Syntax" name="Syntax">语法</h2>
+
+<pre class="syntaxbox"><em>var consoleObj</em> = <em>window</em>.console;
+</pre>
+
+<h2 id="Example" name="Example">示例</h2>
+
+<h3 id="输出信息">输出信息</h3>
+
+<p>第一个例子向控制台输出文字。</p>
+
+<pre class="brush: js">console.log("An error occurred while loading the content");
+</pre>
+
+<p>下边这个例子向控制台打印一个对象,可以通过点击展开组件查看对象的各项属性。</p>
+
+<pre class="brush: js">console.dir(someObject);</pre>
+
+<p>更多示例参考 {{SectionOnPage("/en-US/docs/Web/API/Console", "Usage")}}。</p>
+
+<h2 id="规范">规范</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('Console API')}}</td>
+ <td>{{Spec2('Console API')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<div class="note">
+<p>当前各种浏览器之间的实现还有很多差异,推动一致的工作也在进行当中。</p>
+</div>