V1.0.0
Skip to content

WiTag 标签组件

标签组件,基于 WinDesignAI WiTag 封装,支持点击事件响应。

基础用法

Props API

属性名类型默认值说明
idstring-组件唯一标识(必填)
componentstringWiTag组件类型(必填)
typestringobjectprimary
disableTransitionsbooleanfalse是否禁用过渡动画
actionobject-A2UI v0.9 事件定义
childstring-子组件 ID(标签内容)

path 支持说明

通用绑定格式见 path 数据绑定速查

属性支持 path说明
type动态标签类型(含 @row.tagType 作用域)
action.event.context[].value事件上下文可引用 dataModel
disableTransitions静态配置

绑定示例:

json
{
  "type": { "path": "@row.tagType" },
  "action": {
    "event": {
      "name": "onTagClick",
      "context": [{ "key": "tagType", "value": { "path": "@row.tagType" } }]
    }
  },
  "child": "witag-text"
}

type 类型

说明
primary主要标签
success成功标签
info信息标签
warning警告标签
danger危险标签
error错误标签
urgent紧急标签

action 事件配置

WiTag 支持通过 action 配置点击事件:

json
{
  "action": {
    "event": {
      "name": "onTagClick",
      "context": [
        { "key": "tagType", "value": { "literalString": "primary" } },
        { "key": "tagId", "value": { "path": "/currentTagId" } }
      ]
    }
  }
}
字段类型说明
namestring事件处理函数名(必填)
contextarray事件触发时携带的上下文数据数组

使用示例

可点击标签

json
{
  "id": "witag_001",
  "component": "WiTag",
  "type": "primary",
  "action": {
    "event": {
      "name": "onTagClick",
      "context": [{ "key": "tagType", "value": { "literalString": "primary" } }]
    }
  },
  "child": "witag_001_text"
}

动态数据绑定

json
{
  "id": "witag_002",
  "component": "WiTag",
  "type": "success",
  "action": {
    "event": {
      "name": "onStatusChange",
      "context": [{ "key": "status", "value": { "path": "/userStatus" } }]
    }
  },
  "child": "witag_002_text"
}

数据驱动标签类型

在列表、单选框、复选框等数据驱动场景中,type 可通过数据绑定动态设置:

json
{
  "id": "status-tag",
  "component": "WiTag",
  "type": { "path": "@row.tagType" },
  "child": "status-tag-text"
}

对应数据中每项可指定不同的 tagType

json
[
  { "label": "已完成", "tagType": "success" },
  { "label": "进行中", "tagType": "warning" },
  { "label": "已驳回", "tagType": "danger" }
]