From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/window/console/index.html | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 files/zh-cn/web/api/window/console/index.html (limited to 'files/zh-cn/web/api/window/console') 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 +--- +

{{ APIRef }}

+ +

只读属性Window.console返回一个对{{domxref("Console")}}对象的引用,Window.console提供了向浏览器控制台输出日志信息的方法。这些方法仅应该用于调试,并不应该用来给最终用户呈现信息。

+ +

语法

+ +
var consoleObj = window.console;
+
+ +

示例

+ +

输出信息

+ +

第一个例子向控制台输出文字。

+ +
console.log("An error occurred while loading the content");
+
+ +

下边这个例子向控制台打印一个对象,可以通过点击展开组件查看对象的各项属性。

+ +
console.dir(someObject);
+ +

更多示例参考 {{SectionOnPage("/en-US/docs/Web/API/Console", "Usage")}}。

+ +

规范

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Console API')}}{{Spec2('Console API')}}Initial definition.
+ +
+

当前各种浏览器之间的实现还有很多差异,推动一致的工作也在进行当中。

+
-- cgit v1.2.3-54-g00ecf