JavaScript控制台中的颜色 [英] Colors in JavaScript console
问题描述
Chrome的内置JavaScript控制台可以显示颜色吗?
我希望出现红色错误,橙色警告和 console.log
以绿色显示。这是可能吗?
Firefox(+31)您可以在 console.log
消息中添加CSS:
console.log('%c Oh my heavens!','background:#222; color:#bada55');
同样可以应用于向同一命令添加多个CSS。
Google Chrome的源代码: Paul Irish发表演讲& Webkit更改
Firefox的源: Firefox Web控制台 - 样式消息
Chrome控制台API参考:控制台API参考 p>
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?
In Chrome & Firefox (+31) you can add CSS in console.log
messages:
console.log('%c Oh my heavens! ', 'background: #222; color: #bada55');
The same can be applied for adding multiple CSS to same command.
Source for Google Chrome: Presentation by Paul Irish & Webkit change
Source for Firefox: Firefox Web Console - Styling Messages
Chrome Console API Reference:Console API Reference
这篇关于JavaScript控制台中的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!