更改console.log消息的颜色 [英] Change console.log message color
本文介绍了更改console.log消息的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
console.log(hello world,'#FF0000')
在Chrome / Safari或Firefox?
$ b
函数colorTrace(msg,color){
console.log(%c+ msg,color:+ color +; font-weight:bold;);
}
colorTrace(Test Me,red);
Is there a way to do something like:
console.log("hello world", '#FF0000')
in Chrome/Safari or Firefox ?
解决方案
This works:
function colorTrace(msg, color) {
console.log("%c" + msg, "color:" + color + ";font-weight:bold;");
}
colorTrace("Test Me", "red");
这篇关于更改console.log消息的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文