介绍
组合了颜色选择器、弹出框组件,实现了便捷快速的颜色选择功能。
代码演示
基础使用
vue
<template>
<s-color-picker-popout
v-model:visible="visible"
v-model="color"
title="选择颜色"
show-alpha
show-format
show-presets
/>
<s-list card>
<s-list-item>
<s-button color="primary" @click="visible = true">打开颜色选择器</s-button>
</s-list-item>
<s-list-item>当前颜色:{{ color }}</s-list-item>
<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 visible = ref(false)
const color = ref('')
</script>vue
<template>
<s-color-picker-popout
v-model:visible="visible"
v-model="color"
title="选择颜色"
show-alpha
show-format
show-presets
/>
<s-list card>
<s-list-item>
<s-button color="primary" @click="visible = true">打开颜色选择器</s-button>
</s-list-item>
<s-list-item>当前颜色:{{ color }}</s-list-item>
<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 visible = ref(false)
const color = ref('')
</script>API
ColorPickerPopoutProps
继承 ColorPickerProps 和 FormPopoutProps。
ColorPickerPopoutEmits
| 事件 | 描述 | 类型 |
|---|---|---|
| update:visible | 弹出层显隐变化时触发 | (visible: boolean) => void |
| update:modelValue | 确认选择后触发 | (value: string) => void |
| change | 确认选择后触发 | (value: string) => void |
| confirm | 点击确认按钮时触发 | (value: string) => void |