控制台消息JavaScript与绿色复选标记 [英] console message JavaScript with green checkmark
问题描述
$ b $我想知道是否可能在控制台中出现绿色复选标记,就像console.warn有黄色警告标志,console.error有红色错误标志。 b
我在互联网上搜索过,如果已经有这样的功能,但我找不到它。现在我正在寻找一种在 console.log
消息之前放置图标的方法。
这可能吗? ?
当然是。您可以在Chrome中使用CSS:
console.log(%c hi,background:url(path / to / your / icon.png)0 0 no-repeat; padding-left:20px;);
从文档:
$ b
开发工具支持以下格式
$ b %c根据您提供的CSS样式格式化输出字符串。
注意:
控制台出于某种奇怪的原因不支持后台重复。所以你最好在你的图标上添加一些填充,否则将图标移动到右侧:
console.log(hi%c,background:url(path / to / your / icon.png)0 0 no-repeat; padding-left:20px;);
I was wondering if the was a possibility to have a green checkmark in your console just like console.warn has the yellow warning sign and console.error has the red error sign.
I have searched on the internet if there already was a function like that, but I couldn't find it. Now I'm looking for a way to put an icon before a console.log
message.
Is this possible?
Certainly is. You can use CSS in Chrome:
console.log("%c hi", "background: url(path/to/your/icon.png) 0 0 no-repeat; padding-left: 20px;");
From the documentation:
Dev Tools supports the following format specifiers:
%c Formats the output string according to CSS styles you provide.
Caveat:
The console doesn't support background-repeat for some odd reason. So you'd be better either adding some padding to your icon, or else moving the icon to the right-hand side:
console.log("hi %c", "background: url(path/to/your/icon.png) 0 0 no-repeat; padding-left: 20px;");
这篇关于控制台消息JavaScript与绿色复选标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!