Creates a new inline group in the
Web 控制台
log. This indents following console messages by an additional level, until
console.groupEnd()
被调用。
console.group([label]);
label
console.groupEnd()
.
You can use nested groups to help organize your output by visually associating related messages. To create a new nested block, call
console.group()
。
console.groupCollapsed()
method is similar, but the new block is collapsed and requires clicking a disclosure button to read it.
注意:
From Gecko 9 until Gecko 51, the
groupCollapsed()
method was the same as
group()
. Collapsed groups are fully supported starting in Gecko 52. See
bug 1088360
.
To exit the current group, call
console.groupEnd()
。例如,给出这样的代码:
console.log("This is the outer level");
console.group();
console.log("Level 2");
console.group();
console.log("Level 3");
console.warn("More of level 3");
console.groupEnd();
console.log("Back to level 2");
console.groupEnd();
console.log("Back to the outer level");
输出看起来像这样:
见
在控制台中使用组
在文档编制的
console
了解更多细节。
| 规范 | 状态 | 注释 |
|---|---|---|
|
控制台 API
The definition of 'console.group()' in that specification. |
实时标准 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
group
|
Chrome 1 | Edge 12 | Firefox 4 | IE 11 | Opera Yes | Safari 4 | WebView Android 37 | Chrome Android 18 | Firefox Android 4 | Opera Android ? | Safari iOS ? | Samsung Internet Android 1.0 |
完整支持
兼容性未知