我刚刚读过this SO question/answer它说要改变颜色,使用
console.log("%cYour Message Here", "color:(your color);font-weight:bold;");
我已经对此进行了测试并对其进行了一些修改,然后将其更改为
console.log("Test\n\n%cTest\n\nTest", "color:red;font-weight:bold;");
此输出(其中粗体文本也是红色)
Test
Test
Test
有没有办法引起输出(粗体是红色,斜体是蓝色)
Test
Test
Test
最佳答案
console.log("Test\n\n%cTest\n\n%cTest", "color:red;", "color:blue;");
但是我确实觉得以下内容更具可读性。
console.log("Test");
console.log("%cTest", "color:red");
console.log("%cTest", "color:blue");
检查https://developer.chrome.com/devtools/docs/console-api#consolelogobject-object以获得完整的引用。
关于javascript - console.log 中的多种颜色变化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36553624/