2017-11-06 19:22:02 +08:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
color1: '#409EFF',
|
|
|
|
color2: null,
|
|
|
|
color3: 'rgba(19, 206, 102, 0.8)',
|
2018-03-19 17:20:09 +08:00
|
|
|
color4: '#409EFF',
|
2018-03-19 19:31:38 +08:00
|
|
|
color5: 'rgba(255, 69, 0, 0.68)',
|
2018-03-19 17:20:09 +08:00
|
|
|
predefineColors: [
|
2018-03-19 19:31:38 +08: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 17:20:09 +08:00
|
|
|
]
|
2017-11-06 19:22:02 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$nextTick(() => {
|
|
|
|
const demos = document.querySelectorAll('.source');
|
|
|
|
demos[0].style.padding = '0';
|
|
|
|
});
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.demo-color-picker .block {
|
|
|
|
padding: 30px 0;
|
|
|
|
text-align: center;
|
|
|
|
border-right: solid 1px #EFF2F6;
|
|
|
|
display: inline-block;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
.demo-color-picker .el-color-picker + .el-color-picker {
|
|
|
|
margin-left: 20px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
## ColorPicker
|
|
|
|
|
2017-11-09 00:29:51 +08:00
|
|
|
ColorPicker es un selector de color que soporta varios formatos de color.
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-09 00:29:51 +08:00
|
|
|
### Uso básico
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-12-03 18:03:06 +08:00
|
|
|
:::demo ColorPicker requiere una variable de tipo `string` para ser enlazada a `v-model`.
|
2017-11-06 19:22:02 +08:00
|
|
|
```html
|
|
|
|
<div class="block">
|
2017-11-09 00:29:51 +08:00
|
|
|
<span class="demonstration">Especifica valor por defecto</span>
|
2017-11-06 19:22:02 +08:00
|
|
|
<el-color-picker v-model="color1"></el-color-picker>
|
|
|
|
</div>
|
|
|
|
<div class="block">
|
2017-11-09 00:29:51 +08:00
|
|
|
<span class="demonstration">No especifica valor por defecto</span>
|
2017-11-06 19:22:02 +08:00
|
|
|
<el-color-picker v-model="color2"></el-color-picker>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
color1: '#409EFF',
|
|
|
|
color2: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
|
|
|
### Alpha
|
|
|
|
|
2017-12-03 18:03:06 +08:00
|
|
|
:::demo ColorPicker soporta selección de canales alpha. Para activarlo sólo agrege el atributo `show-alpha`.
|
2017-11-06 19:22:02 +08:00
|
|
|
```html
|
|
|
|
<el-color-picker v-model="color3" show-alpha></el-color-picker>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
color3: 'rgba(19, 206, 102, 0.8)'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2018-03-19 19:31:38 +08:00
|
|
|
### Predefined colors
|
2018-03-19 17:20:09 +08:00
|
|
|
|
2018-03-19 19:31:38 +08:00
|
|
|
:::demo ColorPicker supports predefined color options
|
2018-03-19 17:20:09 +08:00
|
|
|
```html
|
2018-03-19 19:31:38 +08:00
|
|
|
<el-color-picker
|
|
|
|
v-model="color5"
|
|
|
|
show-alpha
|
|
|
|
:predefine="predefineColors">
|
|
|
|
</el-color-picker>
|
2018-03-19 17:20:09 +08:00
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2018-03-19 19:31:38 +08:00
|
|
|
color5: 'rgba(255, 69, 0, 0.68)',
|
2018-03-19 17:20:09 +08:00
|
|
|
predefineColors: [
|
2018-03-19 19:31:38 +08: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 17:20:09 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-11-06 19:22:02 +08: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 {
|
|
|
|
color4: '#409EFF'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
```
|
|
|
|
:::
|
|
|
|
|
2017-11-09 00:29:51 +08:00
|
|
|
### Atributos
|
2017-12-03 18:03:06 +08:00
|
|
|
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
|
|
|
|
| ------------ | ---------------------------------------- | ------- | --------------------- | ---------------------------------------- |
|
|
|
|
| disabled | especifica si se deshabilita el ColorPicker | boolean | — | false |
|
|
|
|
| size | tamaño del ColorPicker | string | — | medium / small / mini |
|
|
|
|
| show-alpha | especifica si se muestra el control deslizante para el valor alpha | boolean | — | false |
|
|
|
|
| color-format | formato de color del `v-model` | string | hsl / hsv / hex / rgb | hex (si show-alpha es false)/ rgb (si show-alpha es true) |
|
|
|
|
| popper-class | nombre de clase para el dropdown del ColorPicker | string | — | — |
|
2018-03-29 10:35:02 +08:00
|
|
|
| predefine | opciones de colores predefinidas | array | — | — |
|
2017-11-06 19:22:02 +08:00
|
|
|
|
2017-11-09 00:29:51 +08:00
|
|
|
### Eventos
|
2017-12-03 18:03:06 +08:00
|
|
|
| Nombre de Evento | Descripción | Parametros |
|
|
|
|
| ---------------- | ---------------------------------------- | ---------------------- |
|
|
|
|
| change | se dispara cuando el valor del input cambia | valor del color |
|
|
|
|
| active-change | se dispara cuando el actual color activo cambia | valor del color activo |
|
|
|
|
|