Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfchengnuo/e3954dd2fad2d1f1de09c6b5d735aef4 to your computer and use it in GitHub Desktop.
Save bfchengnuo/e3954dd2fad2d1f1de09c6b5d735aef4 to your computer and use it in GitHub Desktop.
chrome 控制台 console
console.warn(‘aaaaaa');
在输出信息前面会有一个带感叹号的黄色三角警告符号。似乎比一般的console信息要友好得多了。虽然图标是黄色的,但输出的文字仍然是黑色
console.error(“adfafasdf”)
信息前面会出现一个带叉的红色圆形图标。
这个效果要比警告信息更友好了,字体颜色成红色了。
在Chrome的开发者工具里,console 可以加样式,可以显示缤纷的颜色,甚至图片。简直爽翻了。
具体来说,是可以对输出到console控制台的文字进行CSS控制。
console.log("%c需要输出的信息 ", "css 代码”);
console.log('%cRainbow Text ', 'background-image:-webkit-gradient( linear, left top, right top, color-stop(0, #f22), color-stop(0.15, #f2f), color-stop(0.3, #22f), color-stop(0.45, #2ff), color-stop(0.6, #2f2),color-stop(0.75, #2f2), color-stop(0.9, #ff2), color-stop(1, #f22) );color:transparent;-webkit-background-clip: text;font-size:5em;’);
在Chrome控制台输出图片
console.log("%c", "padding:50px 300px;line-height:120px;background:url('http://wayouliu.duapp.com/img/tagsImg/youth.gif') no-repeat;");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment