Color Picker 颜色选择器

用于选择颜色,支持多种颜色格式。

基础用法

需将 v-model 绑定为字符串类型的变量。

With default value
With no default value

透明度

支持选择带透明度的颜色,设置 show-alpha 即可启用 Alpha 滑块。

预定义颜色

可通过 predefine 传入预置颜色列表。

尺寸

API

属性

名称说明类型默认值
model-value / v-model绑定值string
disabled是否禁用booleanfalse
clearable是否显示清空按钮booleantrue
size组件尺寸enum
show-alpha是否展示透明度滑块booleanfalse
color-formatv-model 的颜色格式enumenum
popper-class下拉弹层的自定义类名string / object''
popper-style下拉弹层的自定义样式string / object
predefine预定义颜色array
validate-event是否触发表单校验booleantrue
tabindex原生 tabindexstring / number0
aria-label a11y无障碍 aria-labelstring
empty-values视为空的取值,参见 config-providerarray
value-on-clear清空后的返回值,参见 config-providerstring / number / boolean / Function
id原生 idstring
teleported是否将弹层挂载到 bodybooleantrue
persistent关闭且 persistentfalse 时是否销毁面板booleantrue
append-to面板挂载到的目标元素CSSSelector / HTMLElement-

事件

名称说明类型
change绑定值变化时触发Function
active-change当前激活颜色变化时触发Function
focus获得焦点时触发Function
blur失去焦点时触发Function
clear点击清空按钮时触发Function

暴露

名称说明类型
color当前颜色对象object
show手动打开颜色选择器Function
hide手动关闭颜色选择器Function
focus聚焦触发器元素Function
blur使触发器失焦Function