【发布时间】:2019-09-02 18:11:55
【问题描述】:
我正在尝试设置 console.log() 的输出样式,以突出显示我的应用程序错误。
到目前为止,这是可行的:
console.log('%cHello World', 'background: #222; color: #bada55');
但这不是:
var text = "Hello World";
var style = "background: #222; color: #bada55";
console.log('%c', text, style);
它只返回background: #222; color: #bada55。我错过了什么?
【问题讨论】:
-
试试这个
console.log('%c '+ text, style);