2020-11-04 10:30:14 +08:00
|
|
|
## Color-picker
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
color-picker は、複数のカラーフォーマットに対応したカラーセレクターです。
|
2020-11-04 10:30:14 +08:00
|
|
|
|
|
|
|
### 基本的な使い方
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
:::demo color-picker は、v-model にバインドするために文字列型の変数が必要です。
|
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
```html
|
|
|
|
<div class="block">
|
|
|
|
<span class="demonstration">With default value</span>
|
|
|
|
<el-color-picker v-model="color1"></el-color-picker>
|
|
|
|
</div>
|
|
|
|
<div class="block">
|
|
|
|
<span class="demonstration">With no default value</span>
|
|
|
|
<el-color-picker v-model="color2"></el-color-picker>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
color1: '#409EFF',
|
2021-09-04 19:29:28 +08:00
|
|
|
color2: null,
|
2020-11-04 10:30:14 +08:00
|
|
|
}
|
2021-09-04 19:29:28 +08:00
|
|
|
},
|
|
|
|
}
|
2020-11-04 10:30:14 +08:00
|
|
|
</script>
|
2021-06-08 13:29:56 +08:00
|
|
|
<!--
|
|
|
|
<setup>
|
|
|
|
|
|
|
|
import { defineComponent, ref } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
setup() {
|
|
|
|
const color1 = ref('#409EFF');
|
|
|
|
const color2 = ref(null);
|
|
|
|
return {
|
|
|
|
color1,
|
|
|
|
color2,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
</setup>
|
|
|
|
-->
|
2020-11-04 10:30:14 +08:00
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### アルファ
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
:::demo color-picker はアルファチャンネルの選択をサポートしています。アルファチャンネルの選択を有効にするには、`show-alpha` アトリビュートを追加するだけです。
|
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
```html
|
|
|
|
<el-color-picker v-model="color" show-alpha></el-color-picker>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-04 19:29:28 +08:00
|
|
|
color: 'rgba(19, 206, 102, 0.8)',
|
2020-11-04 10:30:14 +08:00
|
|
|
}
|
2021-09-04 19:29:28 +08:00
|
|
|
},
|
|
|
|
}
|
2020-11-04 10:30:14 +08:00
|
|
|
</script>
|
2021-06-08 13:29:56 +08:00
|
|
|
<!--
|
|
|
|
<setup>
|
|
|
|
|
|
|
|
import { defineComponent, ref } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
setup() {
|
|
|
|
const color = ref('rgba(19, 206, 102, 0.8)');
|
|
|
|
return {
|
|
|
|
color,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
</setup>
|
|
|
|
-->
|
2020-11-04 10:30:14 +08:00
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### 定義済みの色
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
:::demo color-picker は事前定義されたカラーオプションをサポートしています。
|
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
```html
|
2021-09-04 19:29:28 +08:00
|
|
|
<el-color-picker v-model="color" show-alpha :predefine="predefineColors">
|
2020-11-04 10:30:14 +08:00
|
|
|
</el-color-picker>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
color: 'rgba(255, 69, 0, 0.68)',
|
|
|
|
predefineColors: [
|
|
|
|
'#ff4500',
|
|
|
|
'#ff8c00',
|
|
|
|
'#ffd700',
|
|
|
|
'#90ee90',
|
|
|
|
'#00ced1',
|
|
|
|
'#1e90ff',
|
|
|
|
'#c71585',
|
|
|
|
'rgba(255, 69, 0, 0.68)',
|
|
|
|
'rgb(255, 120, 0)',
|
|
|
|
'hsv(51, 100, 98)',
|
|
|
|
'hsva(120, 40, 94, 0.5)',
|
|
|
|
'hsl(181, 100%, 37%)',
|
|
|
|
'hsla(209, 100%, 56%, 0.73)',
|
2021-09-04 19:29:28 +08:00
|
|
|
'#c7158577',
|
|
|
|
],
|
2020-11-04 10:30:14 +08:00
|
|
|
}
|
2021-09-04 19:29:28 +08:00
|
|
|
},
|
|
|
|
}
|
2020-11-04 10:30:14 +08:00
|
|
|
</script>
|
2021-06-08 13:29:56 +08:00
|
|
|
<!--
|
|
|
|
<setup>
|
|
|
|
|
|
|
|
import { defineComponent, ref } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
setup() {
|
|
|
|
const color = ref('rgba(255, 69, 0, 0.68)');
|
|
|
|
const predefineColors = ref([
|
|
|
|
'#ff4500',
|
|
|
|
'#ff8c00',
|
|
|
|
'#ffd700',
|
|
|
|
'#90ee90',
|
|
|
|
'#00ced1',
|
|
|
|
'#1e90ff',
|
|
|
|
'#c71585',
|
|
|
|
'rgba(255, 69, 0, 0.68)',
|
|
|
|
'rgb(255, 120, 0)',
|
|
|
|
'hsv(51, 100, 98)',
|
|
|
|
'hsva(120, 40, 94, 0.5)',
|
|
|
|
'hsl(181, 100%, 37%)',
|
|
|
|
'hsla(209, 100%, 56%, 0.73)',
|
|
|
|
'#c7158577',
|
|
|
|
]);
|
|
|
|
return {
|
|
|
|
color,
|
|
|
|
predefineColors,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
</setup>
|
|
|
|
-->
|
2020-11-04 10:30:14 +08:00
|
|
|
```
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
:::
|
2020-11-04 10:30:14 +08:00
|
|
|
|
|
|
|
### サイズ
|
|
|
|
|
|
|
|
:::demo
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
```html
|
|
|
|
<el-color-picker v-model="color"></el-color-picker>
|
|
|
|
<el-color-picker v-model="color" size="medium"></el-color-picker>
|
|
|
|
<el-color-picker v-model="color" size="small"></el-color-picker>
|
|
|
|
<el-color-picker v-model="color" size="mini"></el-color-picker>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2021-09-04 19:29:28 +08:00
|
|
|
color: '#409EFF',
|
2020-11-04 10:30:14 +08:00
|
|
|
}
|
2021-09-04 19:29:28 +08:00
|
|
|
},
|
|
|
|
}
|
2020-11-04 10:30:14 +08:00
|
|
|
</script>
|
2021-06-08 13:29:56 +08:00
|
|
|
<!--
|
|
|
|
<setup>
|
|
|
|
|
|
|
|
import { defineComponent, ref } from 'vue';
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
setup() {
|
|
|
|
const color = ref('409EFF');
|
|
|
|
|
|
|
|
return {
|
|
|
|
color,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
</setup>
|
|
|
|
-->
|
2020-11-04 10:30:14 +08:00
|
|
|
```
|
2021-09-04 19:29:28 +08:00
|
|
|
|
2020-11-04 10:30:14 +08:00
|
|
|
:::
|
|
|
|
|
|
|
|
### 属性
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
| --------------------- | ----------------------------------------------- | ------- | --------------------- | ------------------------------------------------------------- |
|
|
|
|
| model-value / v-model | バインディング値 | string | — | — |
|
|
|
|
| disabled | color-picker を無効にするかどうか | boolean | — | false |
|
|
|
|
| size | color-picker のサイズ | string | — | medium / small / mini |
|
|
|
|
| show-alpha | アルファスライダーを表示するかどうか | boolean | — | false |
|
|
|
|
| color-format | v-model の色形式 | string | hsl / hsv / hex / rgb | hex (when show-alpha is false)/ rgb (when show-alpha is true) |
|
|
|
|
| popper-class | color-picker のドロップダウンのカスタムクラス名 | string | — | — |
|
|
|
|
| predefine | 定義済みカラーオプション | array | — | — |
|
2020-11-04 10:30:14 +08:00
|
|
|
|
|
|
|
### イベント
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Event Name | Description | Parameters |
|
|
|
|
| ------------- | ---------------------------------------------------- | ------------------ |
|
|
|
|
| change | 入力値変更時のトリガ | color value |
|
2020-11-04 10:30:14 +08:00
|
|
|
| active-change | 現在アクティブな色が変更されたときにトリガされます。 | active color value |
|