是否有可能呈现HTML到Javascript控制台? [英] Is it possible to render HTML into Javascript console?
问题描述
console.html( < H1>你好!< / H1>中);
会呈现...
您好!
...进入控制台面板。是否有可能?
ps .:为记录,我希望有比log / info / warn /错误消息更多的着色选项。
以某种方式可以使用 示例: CSS格式说明符允许您自定义 支持此功能由所有主要浏览器开发者工具。请参阅 Chrome开发工具的参考资料,< Firefox DevTools 或 Firebug 。 因此,尽管您本身无法使用HTML,但您可以使用CSS来模拟任何需要使用CSS来模仿HTML元素的文本: lang =jsdata-hide =false> I would like to render HTML from a console.(log/info/warn): would render… …into the console panel. Is it possible somehow? ps.: for the record, I would like to have more coloring options than log/info/warn/error messages. In a way it's possible using the CSS format specifier. Example:
The CSS format specifier allows you to customize the display in the
console. Start the string with the specifier and give the style you
wish to apply as the second parameter. This feature is supported by all main browser developer tools. See the reference for the Chrome DevTools, the one for the Firefox DevTools or the one for Firebug. So while you can't use HTML per se, you can style whatever text you want using CSS to mimic many HTML elements:
这篇关于是否有可能呈现HTML到Javascript控制台?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
console.log(%c将使用大蓝色文本格式化,color:blue; font-size:x-large);
$ p $
$ b
控制台中的显示。使用说明符开始字符串并给出您
希望应用为第二个参数的样式。
console.log (%cHello!,font-size:3em);
console.html("<h1>Hello!</h1>");
Hello!
console.log("%cThis will be formatted with large, blue text", "color: blue; font-size: x-large");
console.log("%cHello!", "font-size: 3em");