0%

Node.js控制台如何打印带颜色的字符

1
2
3
4
5
6
7
8
9
10
11
12
13
const Color = {
None: '\033[0m',
Black: '\033[30m',
Red: '\033[31m',
Green: '\033[32m',
Yellow: '\033[33m',
Blue: '\033[34m',
Purple: '\033[35m',
DarkGreen: '\033[36m',
White: '\033[37m',
};
console.log(Color.Red + 'hello',Color.Blue + 'world')

效果如下

tyEgnQ