console.log 有多种颜色变化?
Multiple color change in console.log?
刚刚看了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 以获得完整参考。
console.log("Test");
console.log("%cTest", "color:red;font-weight:bold");
console.log("%cTest", "color:blue;font-style:italic");
刚刚看了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 以获得完整参考。
console.log("Test");
console.log("%cTest", "color:red;font-weight:bold");
console.log("%cTest", "color:blue;font-style:italic");