2020-08-13 15:18:26 +08:00
|
|
|
## Collapse
|
|
|
|
|
|
|
|
Use Collapse to store contents.
|
|
|
|
|
|
|
|
### Basic usage
|
|
|
|
|
|
|
|
You can expand multiple panels
|
|
|
|
|
|
|
|
:::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
|
|
|
:::
|
|
|
|
|
|
|
|
### Accordion
|
|
|
|
|
|
|
|
In accordion mode, only one panel can be expanded at once
|
|
|
|
|
|
|
|
:::demo Activate accordion mode using the `accordion` attribute.
|
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
|
|
|
:::
|
|
|
|
|
|
|
|
### Custom title
|
|
|
|
|
|
|
|
Besides using the `title` attribute, you can customize panel title with named slots, which makes adding custom content, e.g. icons, possible.
|
|
|
|
|
|
|
|
:::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-info"></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
|
|
|
:::
|
|
|
|
|
|
|
|
### Collapse Attributes
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
| --------------------- | ---------------------------------- | ---------------------------------------------------- | --------------- | ------- |
|
|
|
|
| model-value / v-model | currently active panel | string (accordion mode) / array (non-accordion mode) | — | — |
|
|
|
|
| accordion | whether to activate accordion mode | boolean | — | false |
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
### Collapse Events
|
2021-09-04 19:29:28 +08:00
|
|
|
|
|
|
|
| Event Name | Description | Parameters |
|
|
|
|
| ---------- | ---------------------------------- | ------------------------------------------------------------------- |
|
|
|
|
| change | triggers when active panels change | (activeNames: array (non-accordion mode) / string (accordion mode)) |
|
2020-08-13 15:18:26 +08:00
|
|
|
|
|
|
|
### Collapse Item Attributes
|
2021-09-03 11:09:27 +08:00
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|
| --------- | ---------------------------------- | ------------- | --------------- | ------- |
|
|
|
|
| name | unique identification of the panel | string/number | — | — |
|
|
|
|
| title | title of the panel | string | — | — |
|
|
|
|
| disabled | disable the collapse item | boolean | — | — |
|
2021-09-03 11:09:27 +08:00
|
|
|
|
|
|
|
### Collapse Item Slot
|
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
| Name | Description |
|
|
|
|
| ----- | ------------------------------ |
|
|
|
|
| — | content of Collapse Item |
|
|
|
|
| title | content of Collapse Item title |
|