--- title: DisclosureGroup 折叠面板组 description: 管理多个 Disclosure 项展开状态的容器 component: disclosure-group group: 组件 --- ## 用法 ```vue ``` ## 组件结构 ```vue ``` `DisclosureGroup` 用数组管理展开键(空集合为 `[]`),支持字符串或数字 key(`1` 与 `"1"` 不会碰撞)。 ## 示例 ### 受控组件 可使用 `expandedKeys` 与 `update:expandedKeys` 配合 `useDisclosureGroupNavigation` 外部导航。 `useDisclosureGroupNavigation` 为公开 composable:提供 `currentIndex`、`isPrevDisabled`、`isNextDisabled`、`onPrevious`、`onNext`。单选替换集合,多选增量添加;不修改传入集合。 ## 自定义样式 ### Tailwind CSS ### 全局 CSS ```css @layer components { .hv-disclosure-group { @apply w-full; contain: layout style; } } ``` ## 样式参考 - `.hv-disclosure-group` - 基础容器样式,含布局 containment ## API 参考 ### DisclosureGroup | 属性 | 类型 | 默认值 | 描述 | | ------------------------ | ------------------------------ | ------- | ------------------------------------- | | `expandedKeys` | `Array` | - | 受控展开项(`v-model:expanded-keys`) | | `defaultExpandedKeys` | `Array` | `[]` | 初始展开项 | | `allowsMultipleExpanded` | `boolean` | `false` | 是否允许多项同时展开 | | `isDisabled` | `boolean` | `false` | 禁用组内所有 Disclosure | | `as` | `string` | `"div"` | 根元素 | | `class` | `string \| Array \| Object` | - | 合并到根元素 | | 默认插槽 | `{ expandedKeys, isDisabled }` | - | Disclosure 项 | 事件:`update:expandedKeys`、`expandedChange`。 ### useDisclosureGroupNavigation | 属性 | 类型 | 默认值 | 描述 | | ------------------------ | ----------------------------------------- | ------- | ------------- | | `expandedKeys` | `Array` 或 getter | - | 当前展开键 | | `itemIds` | `Array` 或 getter | `[]` | 成员 key 列表 | | `onExpandedChange` | `(keys: Array) => void` | - | 提交新集合 | | `allowsMultipleExpanded` | `boolean` | `false` | 多选增量 | 返回:`currentIndex`、`isPrevDisabled`、`isNextDisabled`、`onPrevious`、`onNext`。 ## 相关组件 [Accordion 手风琴](./accordion) · [Disclosure 折叠面板](./disclosure) · [Button 按钮](./button) ## 相关案例 以下卡片链接至上游 React 案例(新窗口)。