Collapse 折叠器

基本用法

```schema: scope=”body” { “type”: “collapse-group”, “activeKey”: [“1”], “body”: [ { “type”: “collapse”, “key”: “1”, “header”: “标题1”, “body”: “这里是内容1” }, { “type”: “collapse”, “key”: “2”, “header”: “标题2”, “body”: “这里是内容2” }, { “type”: “collapse”, “key”: “3”, “header”: “标题3”, “body”: “这里是内容3” } ] }

  1. ## 手风琴模式
  2. ```schema: scope="body"
  3. {
  4. "type": "collapse-group",
  5. "activeKey": ["1"],
  6. "accordion": true,
  7. "body": [
  8. {
  9. "type": "collapse",
  10. "key": "1",
  11. "header": "标题1",
  12. "body": "这里是内容1"
  13. },
  14. {
  15. "type": "collapse",
  16. "key": "2",
  17. "header": "标题2",
  18. "body": "这里是内容2"
  19. },
  20. {
  21. "type": "collapse",
  22. "key": "3",
  23. "header": "标题3",
  24. "body": "这里是内容3"
  25. }
  26. ]
  27. }

自定义图标

```schema: scope=”body” { “type”: “collapse-group”, “activeKey”: [“1”], “expandIcon”: { “type”: “icon”, “icon”: “caret-right” }, “body”: [ { “type”: “collapse”, “key”: “1”, “header”: “标题1”, “body”: “这里是内容1” }, { “type”: “collapse”, “key”: “2”, “header”: “标题2”, “body”: “这里是内容2” }, { “type”: “collapse”, “key”: “3”, “header”: “标题3”, “body”: “这里是内容3” } ] }

  1. ## 设置图标位置
  2. ```schema: scope="body"
  3. {
  4. "type": "collapse-group",
  5. "expandIconPosition": "right",
  6. "activeKey": ["1"],
  7. "body": [
  8. {
  9. "type": "collapse",
  10. "key": "1",
  11. "header": "标题1",
  12. "body": "这里是内容1"
  13. },
  14. {
  15. "type": "collapse",
  16. "key": "2",
  17. "header": "标题2",
  18. "body": "这里是内容2"
  19. },
  20. {
  21. "type": "collapse",
  22. "key": "3",
  23. "header": "标题3",
  24. "body": "这里是内容3"
  25. }
  26. ]
  27. }

面板嵌套

```schema: scope=”body” { “type”: “collapse-group”, “activeKey”: [“1”], “body”: [ { “type”: “collapse”, “key”: “1”, “header”: “标题1”, “body”: { “type”: “collapse-group”, “activeKey”: [“1”], “body”: [ { “type”: “collapse”, “key”: “1”, “header”: “嵌套面板标题”, “body”: “嵌套面板内容” } ] } }, { “type”: “collapse”, “key”: “2”, “header”: “标题2”, “body”: “这里是内容2” } ] }

  1. ## 折叠面板禁用
  2. ```schema: scope="body"
  3. {
  4. "type": "collapse-group",
  5. "activeKey": ["1"],
  6. "body": [
  7. {
  8. "type": "collapse",
  9. "key": "1",
  10. "header": "标题1",
  11. "body": "这里是内容1"
  12. },
  13. {
  14. "type": "collapse",
  15. "disabled": true,
  16. "key": "2",
  17. "header": "标题2",
  18. "body": "这里是内容2"
  19. }
  20. ]
  21. }

折叠面板图标隐藏

schema: scope="body" { "type": "collapse-group", "body": [ { "type": "collapse", "key": "1", "header": "标题1", "body": "这里是内容1" }, { "type": "collapse", "showArrow": false, "key": "2", "header": "标题2", "body": "这里是内容2" } ] }

CollapseGroup 属性表

属性名 类型 默认值 说明
type string "collapse-group" 指定为 collapse-group 渲染器
activeKey `Array<string \ number \ never> \ string \ number` - 初始化激活面板的key
accordion boolean false 手风琴模式
expandIcon SchemaNode - 自定义切换图标
expandIconPosition string "left" 设置图标位置,可选值`left \ right`

Collapse 属性表

属性名 类型 默认值 说明
type string "collapse" 指定为 collapse 渲染器
disabled boolean false 禁用
collapsed boolean true 初始状态是否折叠
key `string \ number` - 标识
header `string \ SchemaNode` - 标题
body `string \ SchemaNode` - 内容
showArrow boolean true 是否展示图标