我在 NPM 发布了新包: con-colors

链接地址:npmjs.com

con-colors

安装依赖

bash 复制代码
yarn add con-colors

使用

导入:

js 复制代码
import { print } from "con-colors";

使用:

js 复制代码
print.succ("成功的消息");
print.err("失败的消息")

例子:

js 复制代码
import { print } from "con-colors";

for (let i = 0; i < 10; i++) {
    if (i === 6) {
        print.err(`Failure: ${i}. An error has occurred!`)
    }
    print.succ(`Test: ${i}`);
}

其他情况(自定义)

自定义其他颜色,导入颜色函数(colors)

js 复制代码
import { colors, CONSTANT_COLORS } from "con-colors";

使用:

js 复制代码
console.log(colors());

例子:

js 复制代码
import { colors, CONSTANT_COLORS } from "con-colors";

for (let i = 0; i < 10; i++) {
    if (i % 2 === 0) {
        console.log(colors('yellow', `index: ${i}`));
    } else {
        console.log(colors(['cyanBg', CONSTANT_COLORS.red], `index: ${i}`));
    }
}

颜色说明

参数 颜色
'bright' 亮色
'grey' 灰色
'italic' 斜体
'underline' 下划线
'reverse' 反向
'hidden' 隐藏
'black' 黑色
'red' 红色
'green' 绿色
'yellow' 黄色
'blue' 蓝色
'magenta' 品红
'cyan' 青色
'white' 白色
'blackBg' 背景色为黑色
'redBg' 背景色为红色
'greenBg' 背景色为绿色
'yellowBg' 背景色为黄色
'blueBg' 背景色为蓝色
'magentaBg' 背景色为品红
'cyanBg' 背景色为青色
'whiteBg' 背景色为白色
相关推荐
码事漫谈1 小时前
当AI开始“思考”:我们是否真的准备好了?
前端·后端
许杰小刀1 小时前
ctfshow-web文件包含(web78-web86)
android·前端·android studio
我是Superman丶2 小时前
Element UI 表格某行突出悬浮效果
前端·javascript·vue.js
恋猫de小郭2 小时前
你的代理归我了:AI 大模型恶意中间人攻击,钱包都被转走了
前端·人工智能·ai编程
xiaokuangren_2 小时前
前端css颜色
前端·css
hoiii1873 小时前
C# 基于 LumiSoft 实现 SIP 客户端方案
前端·c#
anOnion3 小时前
构建无障碍组件之Meter Pattern
前端·html·交互设计
小码哥_常3 小时前
Spring Boot配置diff:解锁配置管理新姿势
前端
小码哥_常4 小时前
告别onActivityResult!Android数据回传的3大痛点与终极解决方案
前端
hhcccchh4 小时前
1.2 CSS 基础选择器、盒模型、flex 布局、grid 布局
前端·css·css3