V1.0.0
Skip to content

WIcon 图标组件

图标组件,基于 WinDesignNext WIcon 封装,用于显示图标。图标名称来自 @win-design-next/icons-vue

基础用法

Props API

属性名类型默认值说明
idstring-组件唯一标识(必填)
componentstringWIcon组件类型(必填)
namestringobject-
colorstringobject-
sizestringnumberobject

path 支持说明

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

属性支持 path说明
name动态图标名称(dataModel 或 @row.icon
color动态图标颜色
size动态图标尺寸

dataModel 路径示例:

json
{ "name": { "path": "/statusIcon" }, "color": "#409EFF", "size": 20 }

列表模板作用域示例:

json
{ "name": { "path": "@row.icon" }, "color": { "path": "@row.iconColor" } }

name 图标名称

name 对应 @win-design-next/icons-vue 中的图标组件名称,如:

name说明
Edit编辑
Delete删除

更多图标请参考 @win-design-next/icons-vue 文档。

使用示例

固定图标

json
{
  "id": "icon_edit",
  "component": "WIcon",
  "name": "Edit",
  "color": "#409EFF",
  "size": 20
}

数据驱动图标

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

json
{
  "id": "status-icon",
  "component": "WIcon",
  "name": { "path": "@row.icon" },
  "color": { "path": "@row.iconColor" },
  "size": 20
}

对应数据:

json
[
  { "label": "已完成", "icon": "Check", "iconColor": "#67C23A" },
  { "label": "进行中", "icon": "Edit", "iconColor": "#409EFF" },
  { "label": "已驳回", "icon": "Close", "iconColor": "#F56C6C" }
]

与其他组件组合使用

图标常与 WSpace、WTag 等组合使用:

json
[
  {
    "id": "action-space",
    "component": "WSpace",
    "direction": "horizontal",
    "size": "small",
    "align": "center",
    "children": ["icon_edit", "icon_delete"]
  },
  {
    "id": "icon_edit",
    "component": "WIcon",
    "name": "Edit",
    "color": "#409EFF",
    "size": 16
  },
  {
    "id": "icon_delete",
    "component": "WIcon",
    "name": "Delete",
    "color": "#F56C6C",
    "size": 16
  }
]