Skip to content

PickerColor 颜色选择器

介绍

用于颜色选择,通过HSV颜色模型选择,支持透明度设置、颜色预设。

基础用法

通过 v-model 绑定当前选中颜色。

html
<picker-color
  v-model="color"
  title="基础用法"
  @confirm="handleConfirm"
  @cancel="handleCancel"
/>
ts
import { PickerColorSelectedData } from 'vital-design';

const color = ref('#66ccff');

// 确认操作
function handleConfirm(data: PickerColorSelectedData) {
  ...
}

// 取消操作
function handleCancel(data: PickerColorSelectedData) {
  ...
}

限制透明度选择

通过 alpha 属性开启/关闭透明度选择。

html
<picker-color
  v-model="color"
  title="限制透明度选择"
  :alpha="false"
/>
ts
import { PickerColorSelectedData } from 'vital-design';

const color = ref('#66ccff');

自定义颜色预设

通过 colors 属性自定义颜色预设。

html
<picker-color
  v-model="color"
  title="自定义颜色预设"
  :colors="colors"
  @confirm="handleConfirm"
  @cancel="handleCancel"
/>
ts
import { PickerColorSelectedData } from 'vital-design';

const color = ref('#66ccff');

const colors = [
  '#333333',
  '#1989fa',
  '#07c160',
  '#ff976a',
  '#ee0a24',
  '#b38bff',
  '#f3aec3',
  '#f3da5c',
  '#ab7839',
];

API

Props

参数说明类型默认值
v-model选中颜色string-
title标题string-
alpha是否开启透明度设置booleantrue
colors预设颜色列表string[][...]
confirm-button-text确认按钮文字string-
cancel-button-text取消按钮文字string-

代替原始 Props

参数说明类型默认值
custom-id根节点idstring-
custom-class根节点类名ClassValue-
custom-style根节点样式StyleValue-

Events

事件名说明回调参数
click点击时触发MouseEvent
change切换时触发string
confirm确认时触发PickerColorSelectedData
cancel取消时触发PickerColorSelectedData

Slots

名称说明
toolbar工具栏

赣ICP备2025061025号-1