Skip to content

Collapse 折叠面板 ​

基于 Element Plus Collapse 增强的折叠面板组件。

使用折叠面板收纳内容区域。

基本用法 ​

可以同时展开多个面板,面板之间互不影响

Consistency
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;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

手风琴模式 ​

在手风琴模式下,每次只能展开一个面板

通过设置 accordion 属性来激活手风琴模式。

Consistency
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;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

自定义标题 ​

除了使用 title 属性外,还可以通过具名插槽自定义面板标题,实现添加图标等自定义内容的需求。

TIP

title 插槽提供了 isActive 属性,用于标识当前折叠项是否处于激活状态。

自定义图标 ​

除了使用 icon 属性外,还可以通过具名插槽自定义面板项的图标,支持添加个性化内容。

Consistency
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;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

自定义图标位置 ​

通过 expand-icon-position 属性,可以自定义展开图标的位置。

expand icon position:
left

阻止折叠 ​

设置 before-collapse 属性,若返回 false 或返回 Promise 且被 reject,则会阻止面板折叠/展开。

before collapse return:
true
Consistency
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;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

工具栏 ​

自定义折叠项的工具栏内容。

使用 show-export 属性展示内置操作按钮,或通过 toolbar 插槽完全自定义工具栏内容。

Data

Collapse API ​

Collapse 属性 ​

Element Plus Collapse 原生属性
属性名说明类型默认值
model-value / v-model当前激活的面板名称,手风琴模式下类型为 string,否则为 arraystring / array[]
accordion是否开启手风琴模式,开启后每次只能展开一个面板booleanfalse
expand-icon-position设置展开图标的位置enumright
before-collapse折叠状态改变前的钩子函数。若返回 false 或返回 Promise 且被 reject,将阻止折叠状态变更Function—

Collapse 事件 ​

Element Plus Collapse 原生事件
事件名说明类型
change激活面板改变时触发,手风琴模式下参数类型为 string,否则为 arrayFunction

Collapse 插槽 ​

Element Plus Collapse 原生插槽
插槽名说明子标签
default自定义默认内容Collapse Item

Collapse Exposes ​

Element Plus Collapse Exposes
名称说明类型
activeNames当前激活的面板名称object
setActiveNames设置激活的面板名称Function

CollapseItems API ​

CollapseItems 属性 ​

属性名说明类型默认值
title extended面板标题string''
subtitle面板副标题string''
icon extended折叠项的图标string / ComponentArrowRight
showExport是否显示导出按钮,若 onExport 为空,将默认获取子组件 bk-table 的导出功能booleanfalse
onExport导出事件回调Function—
Element Plus CollapseItems 原生属性
属性名说明类型默认值
name面板的唯一标识string / number—
disabled是否禁用该面板booleanfalse

CollapseItems 插槽 ​

插槽名说明类型
title extended折叠面板项标题内容object
icon extended折叠面板项图标内容object
toolbar折叠面板项工具栏内容—
Element Plus CollapseItems 原生插槽
插槽名说明类型
default折叠面板项内容—

CollapseItems Exposes ​

Element Plus CollapseItems Exposes
名称说明类型
isActive当前折叠项是否处于激活态object