2020-08-13 15:18:26 +08:00
## Collapse
Use Collapse para almacenar contenidos.
### Uso básico
Puede expandir varios paneles
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-collapse v-model = "activeNames" @change =" handleChange " >
< el-collapse-item title = "Consistency" name = "1" >
2021-09-04 19:29:28 +08:00
< div >
Consistent with real life: in line with the process and logic of real
life, and comply with languages and habits that the users are used to;
< / div >
< div >
Consistent within interface: all elements should be consistent, such as:
design style, icons and texts, position of elements, etc.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Feedback" name = "2" >
2021-09-04 19:29:28 +08:00
< div >
Operation feedback: enable the users to clearly perceive their operations
by style updates and interactive effects;
< / div >
< div >
Visual feedback: reflect current state by updating or rearranging elements
of the page.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Efficiency" name = "3" >
2021-09-04 19:29:28 +08:00
< div >
Simplify the process: keep operating process simple and intuitive;
< / div >
< div >
Definite and clear: enunciate your intentions clearly so that the users
can quickly understand and make decisions;
< / div >
< div >
Easy to identify: the interface should be straightforward, which helps the
users to identify and frees them from memorizing and recalling.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Controllability" name = "4" >
2021-09-04 19:29:28 +08:00
< div >
Decision making: giving advices about operations is acceptable, but do not
make decisions for the users;
< / div >
< div >
Controlled consequences: users should be granted the freedom to operate,
including canceling, aborting or terminating current operation.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< / el-collapse >
< script >
export default {
data() {
return {
2021-09-04 19:29:28 +08:00
activeNames: ['1'],
}
2020-08-13 15:18:26 +08:00
},
methods: {
handleChange(val) {
2021-09-04 19:29:28 +08:00
console.log(val)
},
},
2020-08-13 15:18:26 +08:00
}
< / script >
2021-06-08 13:32:20 +08:00
<!--
< setup >
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const activeNames = ref(['1']);
const handleChange = (val) => {
console.log(val);
};
return {
activeNames,
handleChange,
};
},
});
< / setup >
-->
2020-08-13 15:18:26 +08:00
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Acordeón
En modo acordeón sólo un panel puede ser expandido a la vez
:::demo Activa el modo acordeón usado el atributo `accordion` .
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-collapse v-model = "activeName" accordion >
< el-collapse-item title = "Consistency" name = "1" >
2021-09-04 19:29:28 +08:00
< div >
Consistent with real life: in line with the process and logic of real
life, and comply with languages and habits that the users are used to;
< / div >
< div >
Consistent within interface: all elements should be consistent, such as:
design style, icons and texts, position of elements, etc.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Feedback" name = "2" >
2021-09-04 19:29:28 +08:00
< div >
Operation feedback: enable the users to clearly perceive their operations
by style updates and interactive effects;
< / div >
< div >
Visual feedback: reflect current state by updating or rearranging elements
of the page.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Efficiency" name = "3" >
2021-09-04 19:29:28 +08:00
< div >
Simplify the process: keep operating process simple and intuitive;
< / div >
< div >
Definite and clear: enunciate your intentions clearly so that the users
can quickly understand and make decisions;
< / div >
< div >
Easy to identify: the interface should be straightforward, which helps the
users to identify and frees them from memorizing and recalling.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Controllability" name = "4" >
2021-09-04 19:29:28 +08:00
< div >
Decision making: giving advices about operations is acceptable, but do not
make decisions for the users;
< / div >
< div >
Controlled consequences: users should be granted the freedom to operate,
including canceling, aborting or terminating current operation.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< / el-collapse >
< script >
export default {
data() {
return {
2021-09-04 19:29:28 +08:00
activeName: '1',
}
},
2020-08-13 15:18:26 +08:00
}
< / script >
2021-06-08 13:32:20 +08:00
<!--
< setup >
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const activeName = ref('1');
return {
activeName,
};
},
});
< / setup >
-->
2020-08-13 15:18:26 +08:00
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Título personalizado
Además de usar el atributo `title` , se puede personalizar el título del panel con slots con nombre, esto hace posible agregar contenido personalizado, por ejemplo: iconos.
:::demo
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
```html
< el-collapse accordion >
< el-collapse-item name = "1" >
2020-11-29 18:50:46 +08:00
< template #title >
2020-08-13 15:18:26 +08:00
Consistency< i class = "header-icon el-icon-information" > < / i >
< / template >
2021-09-04 19:29:28 +08:00
< div >
Consistent with real life: in line with the process and logic of real
life, and comply with languages and habits that the users are used to;
< / div >
< div >
Consistent within interface: all elements should be consistent, such as:
design style, icons and texts, position of elements, etc.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Feedback" name = "2" >
2021-09-04 19:29:28 +08:00
< div >
Operation feedback: enable the users to clearly perceive their operations
by style updates and interactive effects;
< / div >
< div >
Visual feedback: reflect current state by updating or rearranging elements
of the page.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Efficiency" name = "3" >
2021-09-04 19:29:28 +08:00
< div >
Simplify the process: keep operating process simple and intuitive;
< / div >
< div >
Definite and clear: enunciate your intentions clearly so that the users
can quickly understand and make decisions;
< / div >
< div >
Easy to identify: the interface should be straightforward, which helps the
users to identify and frees them from memorizing and recalling.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< el-collapse-item title = "Controllability" name = "4" >
2021-09-04 19:29:28 +08:00
< div >
Decision making: giving advices about operations is acceptable, but do not
make decisions for the users;
< / div >
< div >
Controlled consequences: users should be granted the freedom to operate,
including canceling, aborting or terminating current operation.
< / div >
2020-08-13 15:18:26 +08:00
< / el-collapse-item >
< / el-collapse >
```
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
:::
### Atributos de Collapse
2021-09-04 19:29:28 +08:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| --------------------- | ------------------------------------- | ------------------------------------------------- | ----------------- | ----------- |
| model-value / v-model | panel activo | string (modo acordeón) / array (No modo acordeón) | — | — |
| accordion | especifica si activa el modo acordeón | boolean | — | false |
2020-08-13 15:18:26 +08:00
### Eventos de Collapse
2021-09-04 19:29:28 +08:00
| Nombre de Evento | Descripción | Parametros |
| ---------------- | --------------------------------------------- | ---------------------------------------------------------------- |
| change | se dispara cuando los paneles activos cambian | (activeNames: array (No modo acordeón) / string (modo acordeón)) |
2020-08-13 15:18:26 +08:00
### Atributos de Collapse Item
2021-09-04 19:29:28 +08:00
2020-08-13 15:18:26 +08:00
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto |
| -------- | ----------------------------- | ------------- | ----------------- | ----------- |
| name | identificador único del panel | string/number | — | — |
| title | título del panel | string | — | — |
| disabled | deshabilita el collapse ítem | boolean | — | — |
2021-09-03 11:09:27 +08:00
### Collapse Item Slot
2021-09-04 19:29:28 +08:00
| Nombre | Descripcíon |
| ------ | ------------------------------------- |
| — | contenido de Collapse ítem |
| title | contenido del título de Collapse ítem |