Skip to content

FoldingPanel 折叠面板组件

通过折叠面板收纳内容区域。

温馨提示

本项目参考了 uView-Plus 开源项目的组件开发方式,基于 Vue 3 和 TypeScript 实现了自定义组件。
感谢 uView-Plus 开源项目及其团队成员的贡献,他们的组件开发思路为本项目提供了宝贵地参考。如果需要了解更多组件开发细节,可以参考uView-Plus的 collapse组件 的代码实现。

📌平台差异说明

APP(vue)H5微信小程序支付宝小程序

🏯基本使用示例

注意

index是必填的,他是索引

html
<hy-folding-panel v-model="activeIndex">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-config-provider>

禁用面板

  • 通过设置hy-folding-paneldisabled禁用所以面板
  • 通过设置hy-folding-panel-itemdisabled禁用单个面板
html
<hy-folding-panel v-model="activeIndex" :disabled="true">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-config-provider>

显示边框

  • 通过border设置边框
html
<hy-folding-panel v-model="activeIndex" :border="true">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-config-provider>

设置面板大小

  • 通过设置size设置面板大小
    • small-小面板
    • medium-中面板(默认)
    • large-大面板
html
<hy-folding-panel v-model="activeIndex" size="small">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-config-provider>

自定义面板头部

html
<hy-folding-panel v-model="activeIndex" :disabled="true">
    <hy-folding-panel-item index="fruits">
        <template #header>
            <view class="hy-folding-panel-item__title">自定义头部</view>
        </template>
    </template>
    </hy-folding-panel-item>
    <hy-folding-panel-item index="beverage">
        <template #title>
            <view class="hy-folding-panel-item__title">自定义标题</view>
        </template>
    </hy-folding-panel-item>
</hy-config-provider>

API

FoldingPanel Props

参数说明类型默认值
modelValue当前激活的面板索引,支持v-modelnumber|string-1
accordion是否手风琴模式booleanfalse
disabled是否禁用整个折叠面板组booleanfalse
border是否显示边框booleantrue
size面板头部大小large|medium|smallmedium

FoldingPanelItem Props

参数说明类型默认值
index面板索引(由父组件自动设置)number|string-1
title面板标题string-
value右侧显示的值string-
icon左侧图标string-
iconColor左侧图标颜色string-
iconSize左侧图标大小string|numner-
content面板内容string-
contentHeight内容区域最大高度string|numner150
disabled是否禁用当个面板booleanfalse
defaultOpen默认是否展开booleanfalse
customStyle自定义需要用到的外部样式CSSProperties-

Events

FoldingPanel Emits

事件名说明回调参数
change面板状态改变时触发expanded:内部展开状态, index:索引
open面板打开时触发index:索引
close面板关闭时触发index:索引

FoldingPanelItem Emits

事件名说明回调参数
click改成面板开关状态index:索引
change面板状态改变时触发expanded:内部展开状态, index:索引
open面板打开时触发index:索引
close面板关闭时触发index:索引
child-click子项点击时通知父组件index:索引

Methods

FoldingPanel Expose

事件名说明参数
open打开指定索引的面板index: number|string
close关闭指定索引的面板index: number|string
toggle切换指定索引面板的状态index: number|string
closeAll关闭所有面板-

FoldingPanelItem Expose

事件名说明参数
open打开面板-
close关闭面板-
toggle切换面板状态-
getExpanded获取当前展开状态-

Slots

插槽名说明接收值
default主体部分的内容-
header面板头部-
title面板头部左边内容-
08:44