console.group()方法在控制臺中創(chuàng)建一個新的內(nèi)聯(lián)組。
這會使控制臺消息縮進(jìn)一個附加級別,直到調(diào)用console.groupEnd()為止。
console.group()方法采用可選的參數(shù)label。
console.group(label)
console.log("Hello!");
console.group();
console.log("再次Hello,這次在小組里面!");
console.group();
console.log("再次Hello,這次在另一個小組內(nèi)!");測試看看?/?所有瀏覽器都完全支持console.group()方法:
| Method | ![]() | ![]() | ![]() | ![]() | ![]() |
| console.group() | 是 | 是 | 是 | 是 | 是 |
| 參數(shù) | 描述 |
|---|---|
| label | (可選)組的標(biāo)簽 |
調(diào)用console.group()四次,并帶有label:
console.group("Level 1");
console.group("Level 2");
console.group("Level 3");
console.group("Level 4");測試看看?/?使用console.groupEnd()方法結(jié)束組:
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");測試看看?/?