Skip to content

n-color 色彩 ​

色板选择器:从一组预设色中点选,拿到选中色值。选中色块带主色描边环与对勾,对勾颜色按色值亮度自适应黑白;再点已选中的色 = 取消选中(值为空串)。

组件支持 v-model,也可使用显式绑定::model-value + @update:model-value

平台兼容性 ​

App H5 微信小程序 支付宝小程序 百度小程序 头条小程序 QQ小程序
√ √ √ × × × ×

API ​

属性 ​

参数 说明 类型 默认值 可选值
model-value 当前选中色值(#rrggbb / #rgb),空串 = 未选中 String "" -
colors 色板色值数组;传空数组 = 使用内置默认色板(20 色) Array 内置 20 色 -
columns 每行列数;色块宽度按列数等分 Number 5 -
size 色块边长(px);点击区固定 ≥44px Number 32 -
shape 色块形状:square 小圆角 / circle 圆形 String circle square<br/>circle
disabled 禁用(保留配色降透明度,拦截点选与事件) Boolean false -
custom-class 挂到根节点的额外 class(组件样式表内已定义的类,如右对齐类 n-color--end) String "" -
custom-style 根节点行内样式,如 "justify-content:flex-end" String "" 与 css 相同
swatch-style 微调色块的行内样式,如 "border-radius:2px" String "" 与 css 相同

事件 ​

事件名 说明 回调参数
update:model-value 点选色块后触发(再点已选中色时为空串=取消);配合 :model-value 手动双向绑定 色值字符串
change 点选色块时触发(语义化入口,与 update:model-value 同时发出) 色值字符串

记录 · 思考 · 创作