amis/docs/zh-CN/components/form/button-group.md
2021-01-19 10:20:09 +08:00

3.3 KiB
Executable File

title description type group menuName icon order
Button-Group 按钮集合 0 null Button-Group 6

基本用法

用于将多个按钮在展现上合并到一起。

{
  "type": "form",
  "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
  "controls": [
    {
      "type": "text",
      "name": "name",
      "label": "姓名:"
    },
    {
      "type": "button-group",
      "buttons": [
        {
          "type": "button",
          "label": "Button",
          "actionType": "dialog",
          "dialog": {
            "title": "提示",
            "body": "对,你刚点击了!"
          }
        },

        {
          "type": "submit",
          "label": "提交"
        },

        {
          "type": "reset",
          "label": "重置"
        }
      ]
    }
  ]
}

作为选择器表单项

当不配置 buttons 属性时,button-group还可以作为 选择类表单项 使用。

{
  "type": "form",
  "api": "https://3xsw4ap8wah59.cfc-execute.bj.baidubce.com/api/amis-mock/mock2/form/saveForm",
  "debug": true,
  "controls": [
    {
      "type": "button-group",
      "label": "选项",
      "name": "type",
      "options": [
        {
          "label": "Option A",
          "value": "a"
        },
        {
          "label": "Option B",
          "value": "b"
        }
      ]
    }
  ]
}

更多属性查看 选择类表单项文档

属性表

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

属性名 类型 默认值 说明
options Array<object>Array<string> 选项组
source stringAPI 动态选项组
multiple boolean false 多选
labelField boolean "label" 选项标签字段
valueField boolean "value" 选项值字段
joinValues boolean true 拼接值
extractValue boolean false 提取值
autoFill object 自动填充