多彩console
source link: https://lunashu.org/duo-cai-console-log/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
console.log('\033[42;30m DONE \033[40;32m Compiled successfully in 19987ms\033[0m')
不难发现样例中的关键的代码是类似 \033[42;30m 这种格式的,换成大白话的写法就是 \033[背景色编号;字色编号m 。
字色编号:30黑,31红,32绿,33黄,34蓝,35紫,36深绿,37白色
背景编号:40黑,41红,42绿,43黄,44蓝,45紫,46深绿,47白色
对照色号我们就可以对上面那段代码进行解释:用绿底(42)黑字(30)显示“DONE”,然后使用黑底(40)绿字(32)显示余下的信息,最后还原属性(\033[0m)
还有些比较特殊的标记
- \033[0m 关闭所有属性
- \033[1m 设置高亮度
- \033[4m 下划线
- \033[5m 闪烁
- \033[7m 反显
- \033[8m 消隐
- \033[nA 光标上移n行
- \033[nB 光标下移n行
- \033[nC 光标右移n列
- \033[nD 光标左移n列
- \033[y;xH 设置光标位置(y列x行)
- \033[2J 清屏
- \033[K 清除从光标到行尾的内容
console.log('%c443', 'background-color: red;')
可见有了%c
作为标记后,第二个参数可以像写css
那样去指定样式
Recommend
-
43
今天看到一篇很有意思的一篇文章,如何打印多彩的console.log? 前端的小伙伴对console.log再熟悉不过了,但是至今为止,我都是一直在用其最普通的用法,控制台中打印一条message。没想到,还能给console.log应用样式呢?不知道你们是否
-
35
女主宣言 之前小编有看过编程语句相关统计,echo、print之类的语句,使用最为频繁。但是直接输出的语句,总是那么的普普通通。所以今天小编来给大家分享一篇关于炫酷输出的文章。希望能对大家有所帮助。 P...
-
63
有那么一些已经老去的产品,它们也许早已淡出人们的视线,但每每想到却令我们充满回忆。作为极客之选(微信号 GeekChoice)怀旧栏目,《极客博物馆》希望找到这些曾经带给我们惊喜和感动的产品,带你重拾它们迷人的特质。 不久前...
-
12
iPad Air 4图...
-
12
小米11青春版:多彩机身 极致轻薄 小米11青春版:多彩机身 极致轻薄 天仓零 | 1...
-
10
首次配备M1芯片的新款iMac,强大且多彩 | 爱活网 Evolife.cn 首次配备M1芯片的新款iMac,强大且多彩
-
4
Apple推出新款iMac,多彩超薄采用M1芯片 - 数码窝 Apple推出新款iMac,多彩超薄采用M1芯片 - 数码窝Apple在今日凌晨发布会上推出了多款产品,其中重点之一便是新款iMac。这款产品在设计、性能等方面都有明显变化,行货同时上线...
-
6
苹果发布多彩 iMac,内置 M1 芯片,首次配备 Touch ID 的键盘 产品资讯 | 2021-04-21 苹果发布多彩 iMac,内置 M1 芯片,首次配备...
-
6
iPad Pro 和 iMac 两个系列的重磅更新,应该是刚过去的苹果发布会上最大的两个惊喜。 前者被赋予了几乎超越 MacBook Pro 的强悍硬件,肩负...
-
5
iPhone 13外形曝光:对角线双摄、7款多彩配色 2021年04月28日06:24 快科技2018 我有话说(83人参与) 收藏本文 ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK