console.log在控制台打出css樣式的文字及圖片
谷歌開發者中心上面關於谷歌瀏覽器控制台console.log()的文檔
| Format | Specifier |
|---|---|
| %s | Formats the value as a string. |
| %d or %i | Formats the value as an integer. |
| %f | Formats the value as a floating point value. |
| %o | Formats the value as an expandable DOM element (as in the Elements panel). |
| %O | Formats the value as an expandable JavaScript object. |
| %c | Formats the output string according to CSS styles you provide. |
可以看到,通過占位符%c,可以對輸出到console控制台的文字進行CSS控制。
格式如下:
console.log("%c需要輸出的信息 ", "css 代碼");
輸出3D TEXT
|
|

彩色背景文字
|
|

文字顏色
|
|

設置不同的css
|
|

在Chrome控制台輸出圖片
|
|

參考資料
https://www.cnblogs.com/Wayou/p/chrome_dev_tool_style_console.html
