2016-12-13 14:42:31 +00:00
< script >
export default {
data() {
return {
activeNames: ['1'],
activeName: '1'
};
},
methods: {
handleChange(val) {
console.log(val);
}
}
}
< / script >
2017-05-18 04:28:45 +00:00
< style >
.demo-collapse {
.el-collapse-item__header {
.header-icon {
margin-left: 5px;
}
}
}
< / style >
2016-12-13 14:42:31 +00:00
## Collapse
2016-12-27 06:54:57 +00:00
Use Collapse to store contents.
2016-12-13 14:42:31 +00:00
### Basic usage
2016-12-27 06:54:57 +00:00
You can expand multiple panels
2016-12-13 14:42:31 +00:00
:::demo
```html
< el-collapse v-model = "activeNames" @change =" handleChange " >
< el-collapse-item title = "Consistency" name = "1" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< el-collapse-item title = "Feedback" name = "2" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< el-collapse-item title = "Efficiency" name = "3" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< el-collapse-item title = "Controllability" name = "4" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< / el-collapse >
< script >
export default {
data() {
return {
activeNames: ['1']
};
}
}
< / script >
```
:::
### Accordion
2016-12-27 06:54:57 +00:00
In accordion mode, only one panel can be expanded at once
2016-12-13 14:42:31 +00:00
2016-12-27 06:54:57 +00:00
:::demo Activate accordion mode using the `accordion` attribute.
2016-12-13 14:42:31 +00:00
```html
< el-collapse v-model = "activeName" accordion >
< el-collapse-item title = "Consistency" name = "1" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< el-collapse-item title = "Feedback" name = "2" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< el-collapse-item title = "Efficiency" name = "3" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< el-collapse-item title = "Controllability" name = "4" >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< / el-collapse >
< script >
export default {
data() {
return {
activeName: '1'
};
}
}
< / script >
```
:::
2016-12-27 06:54:57 +00:00
### Custom title
2016-12-13 14:42:31 +00:00
2016-12-30 03:52:41 +00:00
Besides using the `title` attribute, you can customize panel title with named slots, which makes adding custom content, e.g. icons, possible.
2016-12-13 14:42:31 +00:00
:::demo
```html
< el-collapse accordion >
2016-12-30 03:52:41 +00:00
< el-collapse-item name = "1" >
< template slot = "title" >
Consistency< i class = "header-icon el-icon-information" > < / i >
2016-12-13 14:42:31 +00:00
< / template >
2016-12-27 06:54:57 +00: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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
2016-12-27 06:54:57 +00:00
< el-collapse-item title = "Feedback" name = "2" >
< 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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
2016-12-27 06:54:57 +00:00
< el-collapse-item title = "Efficiency" name = "3" >
< 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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
2016-12-27 06:54:57 +00:00
< el-collapse-item title = "Controllability" name = "4" >
< 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 >
2016-12-13 14:42:31 +00:00
< / el-collapse-item >
< / el-collapse >
```
:::
### Collapse Attributes
2016-12-27 06:54:57 +00:00
| Attribute | Description | Type | Accepted Values | Default |
2016-12-13 14:42:31 +00:00
|---------- |-------------- |---------- |-------------------------------- |-------- |
2016-12-27 06:54:57 +00:00
| accordion | whether to activate accordion mode | boolean | — | false |
| value | currently active panel | string (accordion mode)/array (non-accordion mode) | — | — |
2016-12-13 14:42:31 +00:00
### Collapse Events
2016-12-27 06:54:57 +00:00
| Event Name | Description | Parameters |
2016-12-13 14:42:31 +00:00
|---------|---------|---------|
2016-12-27 06:54:57 +00:00
| change | triggers when active panels change | activeNames: array (non-accordion mode)/string (accordion mode) |
2016-12-13 14:42:31 +00:00
### Collapse Item Attributes
2016-12-27 06:54:57 +00:00
| Attribute | Description | Type | Accepted Values | Default |
2016-12-13 14:42:31 +00:00
|---------- |-------------- |---------- |-------------------------------- |-------- |
2016-12-27 06:54:57 +00:00
| name | unique identification of the panel | string/number | — | — |
| title | title of the panel | string | — | — |