WiTag 标签组件
标签组件,基于 WinDesignAI WiTag 封装,支持点击事件响应。
基础用法
Props API
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
id | string | - | 组件唯一标识(必填) |
component | string | WiTag | 组件类型(必填) |
type | string | object | primary |
disableTransitions | boolean | false | 是否禁用过渡动画 |
action | object | - | A2UI v0.9 事件定义 |
child | string | - | 子组件 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" } }
]
}
}
}| 字段 | 类型 | 说明 |
|---|---|---|
name | string | 事件处理函数名(必填) |
context | array | 事件触发时携带的上下文数据数组 |
使用示例
可点击标签
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" }
]