console.log允许你通过css来格式化输出,格式如下:

console.log(‘%c字符串[%c字符串]’, 样式1, [样式2])

其中”%c”为模板字符串

例子:

1
console.log('%cerrow','color:#fff;background:red')

输出结果:
用css改变console.log的输出样式

改变多个样式

1
console.log('%cerrow %cmessage','color:#fff;background:red','color:white;background:#ccc')

输出结果:
用css改变console.log的输出样式

相关文章:

  • 2022-01-16
  • 2021-12-16
  • 2021-09-19
  • 2021-12-31
  • 2021-11-03
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-07
  • 2022-01-09
  • 2021-12-22
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案