自定义文字样式
console.log 中可以通过 %c 表示 css 样式
代码:
let a = 'background: red; color: #fff;'
let b = 'background: rgba(0,0,255,1); color: #fff;'
let c = 'background: #1475B2; color: #fff; '
console.log(`%c UF %c 携手优联 %c 共享前端 `, a, b, c)
console.log('%c 携手优联 共享前端', 'color: #43bb88;font-size: 24px;font-weight: bold;text-decoration: underline;');
控制台输出:
打印(输出)图片
注意:%c 后面有个空格
代码:
console.log("%c ", `background: url('${location.origin}/console/console_log_cn.png') no-repeat center; padding-left:305px;padding-bottom: 195px`);
控制台输出: