Skip to content

A2Button

按钮组件,支持动作配置。

属性

属性类型默认值说明
textstring-按钮文字
typeprimary | success | warning | danger | info | defaultdefault按钮类型
sizelarge | default | smalldefault按钮大小
disabledbooleanfalse禁用状态
iconstring-图标名称或图片 URL(提交/保存/确认/确定类按钮自动使用 Promotion 图标,无需配置)
colorstring-自定义文字颜色(如 #018f75
bgColorstring-自定义背景色(如 #ecfbf9
borderColorstring-自定义边框颜色(如 #c2f0e7
actionobject-点击事件配置,格式见下方说明

基础示例

基础按钮
无内容

按钮类型

按钮类型
无内容

按钮大小

按钮大小
无内容

自定义样式示例

自定义样式按钮
无内容

带图标按钮

icon 属性支持传入图片 URL,会显示在文字左侧。

带图标的按钮
无内容

点击事件

通过 action 属性配置点击事件,外部通过监听 @message 接收。

json
{
  "id": "feedbackBtn",
  "type": "a2-button",
  "props": {
    "text": "已解决"
  },
  "action": {
    "event": {
      "name": "feedbackResolved"
    }
  }
}

事件触发后,外部会收到:

js
{
  type: 'action',
  action: 'click',
  payload: { eventName: 'feedbackResolved' }
}

JSON Schema

json
{
  "id": "buttonId",
  "type": "a2-button",
  "props": {
    "text": "提交",
    "type": "primary",
    "size": "default",
    "icon": "Check",
    "color": "#2260FA",
    "bgColor": "#2260FA",
    "borderColor": "#2260FA"
  },
  "action": {
    "event": {
      "name": "customEvent"
    }
  }
}

A2UI 文档