Chrome Developer Console 中不同颜色的变量类型是什么?

What are the variable types for different colors in Chrome Developer Console?

Chrome开发者控制台打印出变量的值console.log(variable) 根据变量的类型使用不同的颜色。例如 string 值为黑色,null 值为灰色。

  1. 是否有关于这些定义的文档?

  2. 是否可以修改不同值类型的自定义颜色?像基本的控制台消息:console.log("%cBlue!", "color: blue;")

类型的默认颜色是固定的:

您可以使用格式化程序修改某些类型(字符串、整数、浮点数)的输出,但您必须事先知道类型:https://developer.chrome.com/devtools/docs/console-api#consolelogobject-object

It seems that currently its not possible to have custom colors for types with automatic type detection.

Are there any documentation how these are defined?

是的。你可以查看devtools提供的所有console api here.

Is it possible to modify custom colors for different value types?

没有。您只能使用 api。 API 不是通用的,无法添加您自己的颜色或格式。基于日志的类型或使用适当的 api 的任何内容。如 console.logconsole.dirxml 等检查 link 以获得更多 api。

关注 chrome 文档以获取与控制台相关的所有信息

https://developer.chrome.com/devtools/docs/tips-and-tricks