color-gradient-picker-vue3
Color and gradient picker for vue3.js. If you use vue2, plese use color-gradient-picker.color-gradient-picker-vue3 is an upgraded version of color-gradient-picker
Usage
yarn add color-gradient-picker-vue3
Attributes
| introduct | Default |
---|
isGradient | isGradient(是否渐变) | false |
color | solid color(纯色 color) | { red: 255, green: 0, blue: 0, alpha: 1 } |
gradient | gradient color(渐变颜色) | '{"type":"linear","degree":0,"points":[{"id":0,"left":0,"red":0,"green":0,"blue":0,"alpha":1},{"id":1,"left":100,"red":255,"green":0,"blue":0,"alpha":1}]}' | |
cancelText | cancel button text(取消文本) | 'cancel' |
cancelColor | cancel button font-color(取消文本颜色) | '#333' |
cancelBg | cancel button background color (取消背景颜色) | '#fff' |
confirmText | confirm button text(取消文本) | 'confirm' |
confirmColor | confirm button font-color(确认文本颜色) | '#333' |
confirmBg | confirm button background color (确认背景颜色) | '#fff' |
change | Event | |
Example
<template>
<div id="app" :style="{ display: 'flex', textAlign: 'center' }">
<div>
<ColorPicker
:color="color"
cancel-text="cancel"
cancel-color="red"
@change="onChange"
/>
</div>
<div>
<ColorPicker :is-gradient="true" @change="onChange" />
</div>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import ColorPicker from 'color-gradient-picker-vue3';
import 'color-gradient-picker-vue3/dist/style.css';
const color = ref({
red: 255,
green: 0,
blue: 0,
alpha: 1,
});
const onChange = (color) => {
console.log(color);
};
</script>
启动 lib
pnpm install
pnpm dev
pnpm predev
pnpm dev