Colors in JavaScript console

前端 未结 27 2223
说谎
说谎 2020-11-22 11:42

Can Chrome\'s built-in JavaScript console display colors?

I want errors in red, warnings in orange and console.log\'s in green. Is that possible?

27条回答
  •  遇见更好的自我
    2020-11-22 12:09

    I wrote template-colors-web https://github.com/icodeforlove/Console.js to allow us to do this a bit easier

    console.log(c`red ${c`green ${'blue'.bold}.blue`}.green`.red);
    

    The above would be extremely hard to do with the default console.log.

    For a live interactive demo click here.

提交回复
热议问题