wb-color
v1.2.2
Published
获取随机颜色,控制台打印有颜色的文本
Downloads
8
Readme
安装
npm install wb-color
引入
import wbColor from 'wb-color';
获取随机颜色
wbColor.getColor();//返回单个字符串颜色'#66aab1'
wbColor.getColor(3);//返回单个字符串是三个颜色'#e121e1,#23a121,#43bb32'
wbColor.getColor('3');//返回单个字符串是三个颜色'#e121e1,#23a121,#43bb32'
wbColor.getColor('Arrary',3);//返回数组['#e121e1','#23a121','#43bb32'],参数不区分大小写
wbColor.getColor('Arr','3');//返回数组['#e121e1','#23a121','#43bb32'],,参数不区分大小写
控制台打印
//控制台打印带有特殊样式的文本 string:1 ==> Hello World!,分别表示类型,次数,分隔符,以及打印的数据
wbColor.consoleColor('Hello World!');
//控制台打印自定义样式的文本 string:2 ==> Hello World!
wbColor.consoleColor('Hello World!','color:red;font-size:16px');
//控制台打印自定义样式的文本并且自定义设置输出的次数 string:3 ==> Hello World!
wbColor.consoleColor('Hello World!','color:red;font-size:16px',3);
//控制台打印参数还可以设置一个对象,输出颜色红色,字体大小16px的信息 string:1 ==> Hello World!
wbColor.consoleColor('Hello World!',{style:'color:red;font-size:16px'})
//控制台打印参数设置的对象可以有更多的选择,样式属性可以自定义添加,会自动解析,详细参数如下:
/*
{
//样式参数
color:'#43bb88',//设置颜色
'font-size':'20px',//设置字体大小
'font-weight':'bold',//设置字体加粗
'text-decoration':'underline',//设置字体下划线
......
//功能参数
type:true,//选择打印首输出是类型或者是值,默认true,输出是类型
identify : '==>',//设置分隔符,默认是'==>'
startNumber:false,//设置次数,默认false从1开始,每次累计加一
msg:false,//设置msg为true时表示打印首输出提示自定义,默认false
clear:false//设置为true时自动清除控制台所有输出记录,然后再输出本次记录,默认false
}
*/
wbColor.consoleColor('Hello World!',{color:'red',msg:'你好',startNumber:10,identify:'--'})
全局注入控制台打印
window.wb = wbColor.consoleColor;
任意地方使用wb('打印内容')
即可
wb('Hello World!')//控制台特有样式输出 string:1 ==> Hello World!