Button-Group-Select 按钮点选

基本用法

按钮集合当 select 点选用。

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “debug”: true, “body”: [ { “type”: “button-group-select”, “label”: “选项”, “name”: “type”, “options”: [ { “label”: “Option A”, “value”: “a” }, { “label”: “Option B”, “value”: “b” }, { “label”: “Option C”, “value”: “c” } ] } ] }

  1. ## 垂直模式
  2. 配置`"vertical": true`,实现垂直模式
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "api": "/api/mock2/form/saveForm",
  7. "body": [
  8. {
  9. "type": "button-group-select",
  10. "label": "选项",
  11. "name": "type",
  12. "vertical": true,
  13. "options": [
  14. {
  15. "label": "Option A",
  16. "value": "a"
  17. },
  18. {
  19. "label": "Option B",
  20. "value": "b"
  21. },
  22. {
  23. "label": "Option C",
  24. "value": "c"
  25. }
  26. ]
  27. }
  28. ]
  29. }

平铺模式

配置 "tiled": true 实现平铺模式

```schema: scope=”body” { “type”: “form”, “api”: “/api/mock2/form/saveForm”, “body”: [ { “type”: “button-group-select”, “label”: “选项”, “name”: “type”, “tiled”: true, “options”: [ { “label”: “Option A”, “value”: “a” }, { “label”: “Option B”, “value”: “b” }, { “label”: “Option C”, “value”: “c” } ] } ] }

  1. ## 按钮主题样式
  2. 配置 `btnLevel` 统一设置按钮主题样式,注意 `buttons ` `options` 中的`level`属性优先级高于`btnLevel`。配置 `btnActiveLevel` 为按钮设置激活态时的主题样式。
  3. ```schema: scope="body"
  4. {
  5. "type": "form",
  6. "api": "/api/mock2/form/saveForm",
  7. "debug": true,
  8. "body": [
  9. {
  10. "type": "button-group-select",
  11. "label": "选项",
  12. "name": "type",
  13. "btnLevel": "light",
  14. "btnActiveLevel": "warning",
  15. "options": [
  16. {
  17. "label": "Option A",
  18. "value": "a"
  19. },
  20. {
  21. "label": "Option B",
  22. "value": "b"
  23. },
  24. {
  25. "label": "Option C",
  26. "value": "c",
  27. "level": "primary"
  28. }
  29. ]
  30. }
  31. ]
  32. }

属性表

当做选择器表单项使用时,除了支持 普通表单项属性表 中的配置以外,还支持下面一些配置

属性名 类型 默认值 说明
type string "button-group-select" 指定为 button-group-select 渲染器
vertical boolean false 是否使用垂直模式
tiled boolean false 是否使用平铺模式
btnLevel `’link’ \ ‘primary’ \ ‘secondary’ \ ‘info’\ ‘success’ \ ‘warning’ \ ‘danger’ \ ‘light’\ ‘dark’ \ ‘default’` "default" 按钮样式
btnActiveLevel `’link’ \ ‘primary’ \ ‘secondary’ \ ‘info’\ ‘success’ \ ‘warning’ \ ‘danger’ \ ‘light’\ ‘dark’ \ ‘default’` "default" 选中按钮样式
options Array<object>Array<string> 选项组
source stringAPI 动态选项组
multiple boolean false 多选
labelField boolean "label" 选项标签字段
valueField boolean "value" 选项值字段
joinValues boolean true 拼接值
extractValue boolean false 提取值
autoFill object 自动填充

事件表

当前组件会对外派发以下事件,可以通过onEvent来监听这些事件,并通过actions来配置执行的动作,在actions中可以通过event.data.xxx事件参数变量来获取事件产生的数据,详细请查看事件动作

事件名称 事件参数 说明
change event.data.value: string 选中值 选中值变化时触发

动作表

当前组件对外暴露以下特性动作,其他组件可以通过指定actionType: 动作名称componentId: 该组件id来触发这些动作,动作配置可以通过args: {动作配置项名称: xxx}来配置具体的参数,详细请查看事件动作

动作名称 动作配置 说明
clear - 清空
reset - 将值重置为resetValue,若没有配置resetValue,则清空
reload - 重新加载,调用 source,刷新数据域数据刷新(重新加载)
setValue value: string 更新的值 更新数据