介绍
组合了颜色选择器、弹出框、输入框组件,实现了便捷快速的颜色选择功能。
代码演示
基础使用
vue
<template>
<s-list card>
<s-list-item>
<s-color-picker-input
v-model="color"
title="选择颜色"
placeholder="请选择颜色"
show-alpha
show-format
show-presets
clearable
/>
</s-list-item>
<s-list-item title="当前值:" :value="JSON.stringify(color) ?? 'undefined'" />
<s-list-item
title="设置为:"
value="rgb(226, 20, 20)"
hover
arrow
@click="color = 'rgb(226, 20, 20)'"
/>
<s-list-item title="清空" arrow hover @click="color = ''" />
</s-list>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const color = ref('rgba(25, 137, 250, 0.8)')
</script>vue
<template>
<s-list card>
<s-list-item>
<s-color-picker-input
v-model="color"
title="选择颜色"
placeholder="请选择颜色"
show-alpha
show-format
show-presets
clearable
/>
</s-list-item>
<s-list-item title="当前值:" :value="JSON.stringify(color) ?? 'undefined'" />
<s-list-item
title="设置为:"
value="rgb(226, 20, 20)"
hover
arrow
@click="color = 'rgb(226, 20, 20)'"
/>
<s-list-item title="清空" arrow hover @click="color = ''" />
</s-list>
</template>
<script setup lang="js">
import { ref } from 'vue'
const color = ref('rgba(25, 137, 250, 0.8)')
</script>API
ColorPickerInputProps
继承 ColorPickerPopoutProps 和 PopoutInputProps 。
ColorPickerInputEmits
| 事件 | 描述 | 类型 |
|---|---|---|
| update:modelValue | 颜色值变化时触发 | (value: string) => void |
| change | 颜色值变化时触发 | (value: string) => void |
| update:visible | 弹出层显隐变化时触发 | (visible: boolean) => void |
| confirm | 点击确认按钮时触发 | () => void |