[模块推荐]在Node.Js的Console中使用颜色

Console的各种方法默认没有颜色,这样的话,在信息量大的时候真不好找.幸好已经有人提供了Node.Js的颜色模块 Colors.

1.安装

npm install colors

2.引用

新建一个js文件 main.js

var colors = require( "colors")

3.现在就可以使用它了.

1 //使用 colors 模块
2 console.log('红色'.red);
3 console.log('绿色'.green);
4 console.log('下划线加白色'.underline.white)
5 console.log('反转颜色'.inverse);
6 console.log('彩虹色'.rainbow);
7 console.log("乱七八糟".zalgo);

也可以在一行中同时使用

console.log('红色'.red + ',我是蓝色'.blue);

 

4.我们也可以重定义颜色主题.

//自定义主题
colors.setTheme({
silly: 'rainbow',
input: 'grey',
verbose: 'cyan',
prompt: 'grey',
info: 'green',
data: 'grey',
help: 'cyan',
warn: 'yellow',
debug: 'blue',
error: 'red'
});
console.log("this is an error".error);
console.log("this is a warning".warn);

5.这个模块也支持浏览器中调用,包括看包里的example.html

6.效果图.

linux 下的效果

windows 下的效果

 

7.例子包

 http://115.com/file/e6t70mjp#



 

 

 

 

 

 


 

 

 

 

 

 

转载于:https://www.cnblogs.com/seakingii/archive/2012/01/01/2309294.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值