console.log允許你通過css來格式化輸出,格式如下:
console.log(‘%c字符串[%c字符串]’, 樣式1, [樣式2])
其中”%c”為模板字符串
例子:
|
1
|
console.log('%cerrow','color:#fff;background:red')
|
輸出結果:
改變多個樣式
|
1
|
console.log('%cerrow %cmessage','color:#fff;background:red','color:white;background:#ccc')
|
輸出結果:
