手风琴 layout-accordion
2026年7月20日大约 5 分钟
手风琴 layout-accordion
多个可折叠分区,标题即分区名。
- 类型串:
layout-accordion默认尺寸:[320, 480]分类:布局
实时预览
下面渲染的是真实组件(与编辑器 / 运行时同源)。修改右侧「样式参数」,左侧预览实时更新;点击底部「全页面查看」可放大。
属性
下表为本组件特有的属性;
position/size/opacity/background/border/ 联动选中 / 筛选等通用参数见组件手册总览。
basic
| 属性 | 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
sections | 分区列表 | section-list(item=分区) | 分区一,分区二,分区三 | |
single-expand | 单开模式 | boolean | false | |
default-expanded | 加载时展开 | string | 0 | |
show-toggle-all | 全部展开/收起按钮 | boolean | false | |
section-gap | 分区间隙 | number(unit=px,min=0) | 4 | |
container-padding | 整体内边距 | vector<上,右,下,左>(unit=px,min=0) | [0,0,0,0] | |
header-size | 标题高度 | number(unit=px,min=0) | 40 | |
panel-min-height | 默认面板高度 | number(unit=px,min=0) | 120 |
header
| 属性 | 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
toggle-position | 折叠图标位置 | select(radioGroup) | right | 可选:left / right |
toggle-icon | 折叠图标样式 | select(radioGroup) | chevron | 可选:chevron / plus / triangle |
header-bold | 标题加粗 | boolean | true | |
header-font-size | 字号 | number(unit=px,min=0) | 14 | |
header-color | 标题文字色 | color | #e6e8eb | |
header-bg | 收起背景 | color | rgba(255,255,255,0.04) | |
header-active-bg | 展开背景 | color | rgba(47,123,255,0.18) | |
header-radius | 圆角 | number(unit=px,min=0) | 4 | |
header-padding-x | 左右内边距 | number(unit=px,min=0) | 12 | |
header-border-width | 边框宽度 | number(unit=px,min=0) | 0 | |
header-border-color | 边框颜色 | color | rgba(255,255,255,0.16) |
panel
| 属性 | 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
panel-bg | 面板背景 | color | transparent | |
panel-padding | 面板内边距 | number(unit=px,min=0) | 0 | |
panel-radius | 圆角 | number(unit=px,min=0) | 0 | |
panel-border-width | 边框宽度 | number(unit=px,min=0) | 0 | |
panel-border-color | 边框颜色 | color | rgba(255,255,255,0.12) |
数据绑定
无组件特有数据绑定字段(纯样式 / 布局 / 装饰)。
事件
触发器
触发器在预览 / 播放态生效(编辑态点击 = 选中组件)。写在本组件
options.interactions的groups[].trigger里。
| 触发器 | 名称 | 触发时机 | payload(供动作公式 {:字段} 取值) |
|---|---|---|---|
click | 点击 | 点击本组件时触发 | 无 |
mouseEnter | 鼠标移入 | 指针移入组件时触发 | 无 |
mouseLeave | 鼠标移出 | 指针移出组件时触发 | 无 |
appear | 入场 | 组件出现时触发(配合进场动画) | 无 |
disappear | 离场 | 组件消失时触发(配合退场动画) | 无 |
receiveBehaviorEvent | 接收行为事件 | 收到 sendBehaviorEvent 动作或宿主 ctx.emit 投递的事件时触发(按 eventName 匹配) | 发送方携带的 data |
动作
触发器命中后执行的动作。本组件既可发起动作(配在自己的交互里),也可作为其它组件动作的目标。
| 动作 | 名称 | 说明 |
|---|---|---|
changeOption | 修改设置 | 把本组件(或其它组件)的某个属性改为静态值 / 公式动态值 |
switchState | 切换状态 | 切到多状态里的某个状态(state:"" 回默认态) |
appear / disappear | 进 / 退场动画 | 对目标 opacity 做 0↔100 插值的显隐动画 |
完整动作清单(switchScreen / switchWindow / openUrl / sendBehaviorEvent / transfer / executeScript / requestApi 等)与持久化写法见事件交互。
示例
{
"type": "layout-accordion",
"uid": "w_layout_accordion",
"options": {
"position": [40, 40],
"size": [320, 480]
}
}变体示例:单开模式(single-expand)
single-expand: true时同一时刻只展开一个分区,点开新分区自动收起旧分区(再点当前分区可全收起)。