码迷,mamicode.com
首页 > 编程语言 > 详细

[Javascript] Format console.log with CSS and String Template Tags

时间:2017-01-31 17:42:35      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:json   factor   ble   技术   gif   ons   tags   nbsp   image   

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

标签:json   factor   ble   技术   gif   ons   tags   nbsp   image   

原文地址:http://www.cnblogs.com/Answer1215/p/6358904.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!