[Javascript] Format console.log with CSS and String Template Tags
Posted Answer1215
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Javascript] Format console.log with CSS and String Template Tags相关的知识,希望对你有一定的参考价值。
The Chrome console allows you to format messages using CSS properties. This lesson walks you through the syntax of formatting your logs with css then refactoring into a template tag function to make formatting more reusable.
const debug = (label, style, obj) => { console.log(`%c${label}`, `${style}`, `${obj}`); }; debug( `debug: `, `color: white; background-color: grey; padding: 0 0.5em;`, JSON.stringify({name: \'Zhentian\'}));
以上是关于[Javascript] Format console.log with CSS and String Template Tags的主要内容,如果未能解决你的问题,请参考以下文章