有没有人遇到过这种情况
console.info ('hi');
hi // And this hi is printed in black color as opposed to blue
控制台的屏幕截图:
https://postimg.org/image/g8isebbrn/
console.info用于打印蓝色多年!令我惊讶的是,现在不再了。
我在chrome上找不到任何设置,使得输出像那样色盲!
答案 0 :(得分:2)
看起来像这是缩进设计,去图,但..这里是一个出路作为替代!
console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");
不要忘记那里的%c
!
要将其包装在一个函数中,您可以使用此kick-starter代码:
function sysConsole(messageType,message){
if ( messageType === 'info') {
s = '%c' + '##' + messageType + ': ' + message;
// the ## will enable you to do filtering at the console
// by typing ##info
console.log (s, 'color: blue;');
}
// you can have other messageTypes later (to be wired for different colors )
return false;
}
为了未来的灵感,请转到https://developers.google.com/web/tools/chrome-devtools/console/console-write