2017-02-07 16:11:53 +00:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2017-09-30 07:50:04 +00:00
|
|
|
color1: '#409EFF',
|
2017-02-07 16:11:53 +00:00
|
|
|
color2: null,
|
2017-09-14 09:28:07 +00:00
|
|
|
color3: 'rgba(19, 206, 102, 0.8)',
|
2018-03-19 09:20:09 +00:00
|
|
|
color4: '#409EFF',
|
2018-03-19 11:31:38 +00:00
|
|
|
color5: 'rgba(255, 69, 0, 0.68)',
|
2018-03-19 09:20:09 +00:00
|
|
|
predefineColors: [
|
2018-03-19 11:31:38 +00:00
|
|
|
'#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'
|
2018-03-19 09:20:09 +00:00
|
|
|
]
|
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>
|
|
|
|
|
2017-05-18 04:28:45 +00:00
|
|
|
<style>
|
|
|
|
.demo-color-picker .block {
|
|
|
|
padding: 30px 0;
|
|
|
|
text-align: center;
|
|
|
|
border-right: solid 1px #EFF2F6;
|
2017-09-29 07:37:50 +00:00
|
|
|
display: inline-block;
|
2017-05-18 04:28:45 +00:00
|
|
|
width: 50%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
&:last-child {
|
|
|
|
border-right: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.demo-color-picker .demonstration {
|
|
|
|
display: block;
|
|
|
|
color: #8492a6;
|
|
|
|
font-size: 14px;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
2017-09-14 09:28:07 +00:00
|
|
|
.demo-color-picker .el-color-picker + .el-color-picker {
|
|
|
|
margin-left: 20px;
|
|
|
|
}
|
2017-05-18 04:28:45 +00:00
|
|
|
</style>
|
|
|
|
|
2017-02-07 16:11:53 +00:00
|
|
|
## 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-09-30 07:50:04 +00:00
|
|
|
color1: '#409EFF',
|
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>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2018-03-19 11:31:38 +00:00
|
|
|
### Predefined colors
|
2018-03-19 09:20:09 +00:00
|
|
|
|
2018-03-19 11:31:38 +00:00
|
|
|
:::demo ColorPicker supports predefined color options
|
2018-03-19 09:20:09 +00:00
|
|
|
```html
|
2018-03-19 11:31:38 +00:00
|
|
|
<el-color-picker
|
|
|
|
v-model="color5"
|
|
|
|
show-alpha
|
|
|
|
:predefine="predefineColors">
|
|
|
|
</el-color-picker>
|
2018-03-19 09:20:09 +00:00
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2018-03-19 11:31:38 +00:00
|
|
|
color5: 'rgba(255, 69, 0, 0.68)',
|
2018-03-19 09:20:09 +00:00
|
|
|
predefineColors: [
|
2018-03-19 11:31:38 +00:00
|
|
|
'#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'
|
2018-03-19 09:20:09 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
|
2017-09-14 09:28:07 +00:00
|
|
|
### Sizes
|
|
|
|
|
|
|
|
:::demo
|
|
|
|
```html
|
|
|
|
<el-color-picker v-model="color4"></el-color-picker>
|
|
|
|
<el-color-picker v-model="color4" size="medium"></el-color-picker>
|
|
|
|
<el-color-picker v-model="color4" size="small"></el-color-picker>
|
|
|
|
<el-color-picker v-model="color4" size="mini"></el-color-picker>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2017-10-01 12:16:16 +00:00
|
|
|
color4: '#409EFF'
|
2017-09-14 09:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-02-07 16:11:53 +00:00
|
|
|
### Attributes
|
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
|---------- |-------- |---------- |------------- |-------- |
|
2017-09-14 09:28:07 +00:00
|
|
|
| disabled | whether to disable the ColorPicker | boolean | — | false |
|
|
|
|
| size | size of ColorPicker | string | — | medium / small / mini |
|
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) |
|
2017-10-04 12:34:46 +00:00
|
|
|
| popper-class | custom class name for ColorPicker's dropdown | string | — | — |
|
2018-03-19 11:31:38 +00:00
|
|
|
| predefine | predefined color options | array | — | — |
|
2017-02-24 19:33:53 +00:00
|
|
|
|
|
|
|
### Events
|
|
|
|
| Event Name | Description | Parameters |
|
|
|
|
|---------|--------|---------|
|
2017-07-10 03:59:08 +00:00
|
|
|
| change | triggers when input value changes | color value |
|
|
|
|
| active-change | triggers when the current active color changes | active color value |
|