2017-02-07 16:11:53 +00:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2017-02-22 07:14:54 +00:00
|
|
|
color1: '#20a0ff',
|
2017-02-07 16:11:53 +00:00
|
|
|
color2: null,
|
2017-02-22 07:14:54 +00:00
|
|
|
color3: 'rgba(19, 206, 102, 0.8)'
|
2017-02-07 16:11:53 +00:00
|
|
|
};
|
2017-02-22 07:14:54 +00:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const demos = document.querySelectorAll('.source');
|
|
|
|
demos[0].style.padding = '0';
|
|
|
|
});
|
|
|
|
},
|
2017-02-07 16:11:53 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
## ColorPicker
|
|
|
|
|
2017-02-22 07:14:54 +00:00
|
|
|
ColorPicker is a color selector supporting multiple color formats.
|
2017-02-07 16:11:53 +00:00
|
|
|
|
2017-02-22 07:14:54 +00:00
|
|
|
### Basic usage
|
2017-02-07 16:11:53 +00:00
|
|
|
|
2017-02-22 07:14:54 +00:00
|
|
|
:::demo ColorPicker requires a string typed variable to be bound to v-model.
|
2017-02-07 16:11:53 +00:00
|
|
|
```html
|
|
|
|
<div class="block">
|
2017-02-22 07:14:54 +00:00
|
|
|
<span class="demonstration">With default value</span>
|
2017-02-07 16:11:53 +00:00
|
|
|
<el-color-picker v-model="color1"></el-color-picker>
|
|
|
|
</div>
|
|
|
|
<div class="block">
|
2017-02-22 07:14:54 +00:00
|
|
|
<span class="demonstration">With no default value</span>
|
2017-02-07 16:11:53 +00:00
|
|
|
<el-color-picker v-model="color2"></el-color-picker>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2017-02-22 07:14:54 +00:00
|
|
|
color1: '#20a0ff',
|
2017-02-07 16:11:53 +00:00
|
|
|
color2: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-02-22 07:14:54 +00:00
|
|
|
### Alpha
|
2017-02-07 16:11:53 +00:00
|
|
|
|
2017-02-22 07:14:54 +00:00
|
|
|
:::demo ColorPicker supports alpha channel selecting. To activate alpha selecting, just add the `show-alpha` attribute.
|
2017-02-07 16:11:53 +00:00
|
|
|
```html
|
2017-02-22 07:14:54 +00:00
|
|
|
<el-color-picker v-model="color3" show-alpha></el-color-picker>
|
2017-02-07 16:11:53 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2017-02-22 07:14:54 +00:00
|
|
|
color3: 'rgba(19, 206, 102, 0.8)'
|
2017-02-07 16:11:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Attributes
|
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
|---------- |-------- |---------- |------------- |-------- |
|
2017-02-22 07:14:54 +00:00
|
|
|
| show-alpha | whether to display the alpha slider | boolean | — | false |
|
2017-02-24 19:33:53 +00:00
|
|
|
| color-format | color format of v-model | string | hsl / hsv / hex / rgb | hex (when show-alpha is false)/ rgb (when show-alpha is true) |
|
|
|
|
|
|
|
|
### Events
|
|
|
|
| Event Name | Description | Parameters |
|
|
|
|
|---------|--------|---------|
|
|
|
|
| change | triggers when input value changes | color value |
|